-
Notifications
You must be signed in to change notification settings - Fork 300
feat(examples): adds example for initiating mint order #6662
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
| const environment = 'test'; | ||
| const accessToken = ''; | ||
| const enterpriseId = ''; | ||
| const walletId = ''; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mention that this needs to be goAccountid
| sequenceId: order.id, // IMPORTANT: Use the order ID as the sequence ID | ||
| walletPassphrase, | ||
| }); | ||
| console.log('Mint order process completed successfully!'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe fetch the order once here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you add more descriptive comments
| /** | ||
| * Initiate a Mint Order for a Stablecoin | ||
| * | ||
| * Copyright 2023, BitGo, Inc. All Rights Reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * Copyright 2023, BitGo, Inc. All Rights Reserved. | |
| * Copyright 2025, BitGo, Inc. All Rights Reserved. |
| try { | ||
| // Custom API path helper function | ||
| const stablecoinUrl = (path: string) => { | ||
| console.log(common.Environments[bitgo.getEnv()].uri + '/api/stablecoin/v1' + path); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| console.log(common.Environments[bitgo.getEnv()].uri + '/api/stablecoin/v1' + path); |
| // STEP - 3: Initiates the mint order | ||
| const orderRequestBody = { | ||
| sourceWalletId: walletId, | ||
| destinationWalletId: trustAccountWalletId, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
destinationWalletId is wrong here. Fixing in the follow-up PR - #6663
| amount: fromAmount, | ||
| } | ||
| ], | ||
| sequenceId: newOrder.id, // IMPORTANT: Use the order ID as the sequence ID |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As part of input sanitization, we can check for nullity of order id. Something FE can also do if not already doing.
| const constants = await bitgo.get(stablecoinUrl(`/${stablecoin}/constants`)).send(); | ||
| console.log('constants:', constants.body); | ||
| // Extract the treasury account wallet ID from the constants response | ||
| const trustAccountWalletId = constants.body.trustAccountWalletId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const trustAccountWalletId = constants.body.trustAccountWalletId; | |
| const treasuryAccountWalletId = constants.body.trustAccountWalletId; |
| console.log('constants:', constants.body); | ||
| // Extract the treasury account wallet ID from the constants response | ||
| const trustAccountWalletId = constants.body.trustAccountWalletId; | ||
| if (!trustAccountWalletId) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if (!trustAccountWalletId) { | |
| if (!treasuryAccountWalletId) { |
| // Extract the treasury account wallet ID from the constants response | ||
| const trustAccountWalletId = constants.body.trustAccountWalletId; | ||
| if (!trustAccountWalletId) { | ||
| throw new Error(`Trust account wallet ID not found for ${stablecoin}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| throw new Error(`Trust account wallet ID not found for ${stablecoin}`); | |
| throw new Error(`Treasury account wallet ID not found for ${stablecoin}`); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Similar comments as https://github.com/BitGo/BitGoJS/pull/6663/files#r2264906901
| const usdcoin = 'tfiatusd'; | ||
| const ofcUsdCoin = 'ofctusd'; | ||
| const stablecoin = 'tbsc:usd1'; | ||
| const fromAmount = '3000'; // in base units, e.g., 3000 for 30 USD |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| const fromAmount = '3000'; // in base units, e.g., 3000 for 30 USD | |
| const fromAmount = '3000'; // in cents, e.g., 3000 for 30 USD |
?
feat(examples): adds example for initiating mint order
TICKET: TMS-1303
Created Order:
GoAccount Withdraw initiated:
Deposit confirmed on the Treasury GoAccount:
Output of the script:
assets: [ { id: '08c1271e-b15d-4af8-8929-f75383903da4', token: 'tfiatusd', name: 'Testnet US Dollar', decimals: 2, isIssuedByBitgo: false }, { id: '5e4f0e5e-b8ce-431c-8a62-62e54e32bb82', token: 'tusds', name: 'Testnet USD Standard', decimals: 6, isIssuedByBitgo: true, chain: 'hteth', backingAsset: 'tfiatusd' }, { id: '0354c858-912b-4a65-b3e1-9b29a5f8573a', token: 'hteth:usd1', name: 'Holesky Testnet USD1', decimals: 18, isIssuedByBitgo: false, chain: 'hteth', backingAsset: 'tfiatusd' }, { id: 'bfd0daec-f849-4b96-bdb6-6373bffeb9b6', token: 'tbsc:usd1', name: 'Testnet BSC USD1', decimals: 18, isIssuedByBitgo: false, chain: 'tbsc', backingAsset: 'tfiatusd' }, { id: '49ff49ea-3355-4717-bbb0-5e8f5cae2202', token: 'hteth:gousd', name: 'Testnet goUSD', decimals: 6, isIssuedByBitgo: true, chain: 'hteth', backingAsset: 'tfiatusd' }, { id: '78551a7f-17d1-4e81-b6a9-3c6e960337f4', token: 'ttrx:usd1', name: 'Testnet Tron USD1', decimals: 18, isIssuedByBitgo: false, chain: 'ttrx', backingAsset: 'fiatusd' } ] https://app.bitgo-test.com/api/stablecoin/v1/tbsc:usd1/constants constants: { trustAccountWalletId: '67c1a025f9999f485f7a71aa26a1da4c' } https://app.bitgo-test.com/api/stablecoin/v1/enterprise/68493007566b5577218b1eab1cf40cf3/order Order created: { id: 'e42edb0a-55fa-4790-ae5c-ee625ce477df', fromAssetId: '08c1271e-b15d-4af8-8929-f75383903da4', fromAmount: '3000', toAssetId: 'bfd0daec-f849-4b96-bdb6-6373bffeb9b6', toAmount: '30000000000000000000', type: 'mint', destinationType: 'go_account', status: 'created', enterpriseId: '68493007566b5577218b1eab1cf40cf3', userId: '628ca09d1b78a6000750274f0775571a', sourceWalletId: '68493027063dd39cffb65e7f685af841', destinationWalletId: '67c1a025f9999f485f7a71aa26a1da4c', destinationAddress: '0xb278577ce4141c26182fb69c16b9dabf777f1e95', createdAt: '2025-08-08T12:25:57.073Z', updatedAt: '2025-08-08T12:25:57.073Z' } Mint order process completed successfully! New Transaction: { "transfer": { "entries": [ { "address": "address", "wallet": "68493027063dd39cffb65e7f685af841", "value": -3000, "valueString": "-3000" }, { "address": "67c1a025f9999f485f7a71aa26a1da4c", "value": 3000, "valueString": "3000" } ], "id": "6895ecdb716ce06141586c76f3b16dcf", "coin": "ofctusd", "wallet": "68493027063dd39cffb65e7f685af841", "walletType": "trading", "enterprise": "68493007566b5577218b1eab1cf40cf3", "organization": "68493008566b5577218b210236d7922c", "txid": "79a7bfd69e32fc4c3d632b7e117f72a35a380dd599958e1088f82a514ecc9cd9", "txidType": "transactionHash", "height": 999999999, "heightId": "999999999-6895ecdb716ce06141586c76f3b16dcf", "date": "2025-08-08T12:26:05.191Z", "type": "send", "value": -3000, "valueString": "-3000", "intendedValueString": "-3000", "baseValue": -3000, "baseValueString": "-3000", "baseValueWithoutFees": -3000, "baseValueWithoutFeesString": "-3000", "feeString": "0", "payGoFee": 0, "payGoFeeString": "0", "usd": -30, "usdRate": 1, "state": "signed", "instant": false, "isReward": false, "isUnlock": false, "isFee": false, "senderInformationVerified": false, "tags": [ "68493027063dd39cffb65e7f685af841", "68493007566b5577218b1eab1cf40cf3" ], "history": [ { "date": "2025-08-08T12:26:05.191Z", "action": "signed" }, { "date": "2025-08-08T12:26:02.932Z", "user": "628ca09d1b78a6000750274f0775571a", "action": "created" } ], "signedDate": "2025-08-08T12:26:05.191Z", "coinSpecific": { "transactionType": "BOOK_TRANSFER", "fees": [], "recommendedBackingWalletSubtype": "custodialCold", "autoApproveBackingTransfer": true }, "sequenceId": "e42edb0a-55fa-4790-ae5c-ee625ce477df", "metadata": [], "signedTime": "2025-08-08T12:26:05.191Z", "createdTime": "2025-08-08T12:26:02.932Z" }, "txid": "79a7bfd69e32fc4c3d632b7e117f72a35a380dd599958e1088f82a514ecc9cd9", "tx": "{\"transaction\":\"{\\\"coin\\\":\\\"ofctusd\\\",\\\"recipients\\\":[{\\\"address\\\":\\\"67c1a025f9999f485f7a71aa26a1da4c\\\",\\\"amount\\\":\\\"3000\\\"}],\\\"fromAccount\\\":\\\"68493027063dd39cffb65e7f685af841\\\",\\\"nonce\\\":\\\"4df4fa5b-122b-4763-99cd-80705c0fccac\\\",\\\"timestamp\\\":\\\"2025-08-08T12:26:01.183Z\\\",\\\"feeString\\\":\\\"0\\\",\\\"shortCircuitBlockchainTransfer\\\":false,\\\"isIntraJXTransfer\\\":true}\",\"signature\":\"20d0632caf8ab8879bd298a2b493396eb092bf0065e8de9fabbd24cfbb8eb697894bd433cc34395bc308782bee25ae4472738b66c18695294ccadcc63906938872\"}", "status": "signed" }