Skip to content

Commit

Permalink
Refactor mint() of AssetScheme to createMintTransaction()
Browse files Browse the repository at this point in the history
  • Loading branch information
joojis committed Jul 19, 2018
1 parent 53cab11 commit d0c467a
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion API.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ In this example, we want to create an asset called "Gold". Thus, we define a new
```
After Gold has been defined in the scheme, the amount that is minted but belong to someone initially. In this example, we create 10000 gold for Alice.
```javascript
const mintTx = goldAssetScheme.mint(aliceAddress);
const mintTx = goldAssetScheme.createMintTransaction({ recipient: aliceAddress });
```
Then, the AssetMintTransaction is processed with the following code:
```javascript
Expand Down
2 changes: 1 addition & 1 deletion examples/mint-and-transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ async function sendTransaction(tx) {
registrar: null,
})

const mintTx = goldAssetScheme.mint(aliceAddress);
const mintTx = goldAssetScheme.createMintTransaction({ recipient: aliceAddress });

await sendTransaction(mintTx);
const mintTxInvoice = await sdk.rpc.chain.getTransactionInvoice(mintTx.hash(), 5 * 60 * 1000);
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/Rpc.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ describe("rpc", () => {
metadata: "metadata",
amount: 10,
registrar: null
}).mint(await sdk.key.createPubKeyAddress());
}).createMintTransaction({ recipient: await sdk.key.createPubKeyAddress() });
const parcel = sdk.core.createChangeShardStateParcel({
transactions: [mintTransaction],
});
Expand Down
2 changes: 1 addition & 1 deletion integration_tests/Transaction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ test("AssetTransferTransaction fromJSON", async () => {
metadata: "metadata of non-permissioned asset",
amount: 100,
registrar: null,
}).mint(addressA);
}).createMintTransaction({ recipient: addressA });
await sendTransactions({ transactions: [mintTx] });
const firstAsset = await sdk.rpc.chain.getAsset(mintTx.hash(), 0);

Expand Down
2 changes: 1 addition & 1 deletion integration_tests/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const sendTransactions = async ({ transactions }) => {
export const mintAsset = async ({ metadata, amount, lockScriptHash, registrar }) => {
const assetScheme = sdk.core.createAssetScheme({ metadata, amount, registrar });
const assetAddress = sdk.key.classes.AssetTransferAddress.fromLockScriptHash(lockScriptHash);
const assetMintTransaction = assetScheme.mint(assetAddress);
const assetMintTransaction = assetScheme.createMintTransaction({ recipient: assetAddress });
return {
...await sendTransactions({ transactions: [assetMintTransaction] }),
assetMintTransaction
Expand Down
6 changes: 3 additions & 3 deletions src/core/AssetScheme.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,15 @@ export class AssetScheme {
};
}

mint(address: AssetTransferAddress, options: { nonce?: number } = {}): AssetMintTransaction {
const { nonce = 0 } = options;
createMintTransaction(params: { recipient: AssetTransferAddress, nonce?: number }): AssetMintTransaction {
const { recipient, nonce = 0 } = params;
const { networkId, metadata, amount, registrar } = this;
return new AssetMintTransaction({
networkId,
metadata,
output: {
amount,
...address.getLockScriptHashAndParameters(),
...recipient.getLockScriptHashAndParameters(),
},
registrar,
nonce,
Expand Down
4 changes: 2 additions & 2 deletions src/key/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ export class Key {

/**
* Creates AssetTransferAddress for non-standard P2PK asset.
* To use this address AssetScheme.mint() or Asset.transfer().
* To use this address AssetScheme.createMintTransaction() or Asset.transfer().
* @returns AssetTransferAddress
*/
createPubKeyAddress(): Promise<AssetTransferAddress> {
Expand All @@ -39,7 +39,7 @@ export class Key {

/**
* Creates AssetTransferAddress for the standard P2PKH asset.
* To use this address, see AssetScheme.mint() or Asset.transfer().
* To use this address, see AssetScheme.createMintTransaction() or Asset.transfer().
* @returns AssetTransferAddress
*/
createPubKeyHashAddress(): Promise<AssetTransferAddress> {
Expand Down

0 comments on commit d0c467a

Please sign in to comment.