From 70459e53f189bac7c1631a9a70a630eb844a7f18 Mon Sep 17 00:00:00 2001 From: Kevin Li Date: Mon, 17 Jul 2023 09:55:46 -0500 Subject: [PATCH] feat(sdk-coin-stx): update stx staking contract name Ticket: EA-790 --- modules/sdk-coin-stx/src/lib/constants.ts | 2 +- modules/sdk-coin-stx/src/lib/contractBuilder.ts | 2 +- modules/sdk-coin-stx/test/fixtures.ts | 8 ++++---- modules/sdk-coin-stx/test/unit/resources.ts | 14 +++++++------- .../unit/transactionBuilder/contractBuilder.ts | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/modules/sdk-coin-stx/src/lib/constants.ts b/modules/sdk-coin-stx/src/lib/constants.ts index 90f7af3027..e9723a2a0f 100644 --- a/modules/sdk-coin-stx/src/lib/constants.ts +++ b/modules/sdk-coin-stx/src/lib/constants.ts @@ -1,6 +1,6 @@ export const FUNCTION_NAME_SENDMANY = 'send-many'; export const CONTRACT_NAME_SENDMANY = 'send-many-memo'; -export const CONTRACT_NAME_STAKING = 'pox-2'; +export const CONTRACT_NAME_STAKING = 'pox-3'; export const VALID_CONTRACT_FUNCTION_NAMES = [ 'stack-stx', diff --git a/modules/sdk-coin-stx/src/lib/contractBuilder.ts b/modules/sdk-coin-stx/src/lib/contractBuilder.ts index d1814a27a6..c0fab733ad 100644 --- a/modules/sdk-coin-stx/src/lib/contractBuilder.ts +++ b/modules/sdk-coin-stx/src/lib/contractBuilder.ts @@ -61,7 +61,7 @@ export class ContractBuilder extends AbstractContractBuilder { throw new InvalidParameterValueError('Invalid name'); } if (name !== CONTRACT_NAME_STAKING && name !== CONTRACT_NAME_SENDMANY) { - throw new InvalidParameterValueError('Only pox-2 and send-many-memo contracts supported'); + throw new InvalidParameterValueError('Only pox-3 and send-many-memo contracts supported'); } this._contractName = name; return this; diff --git a/modules/sdk-coin-stx/test/fixtures.ts b/modules/sdk-coin-stx/test/fixtures.ts index 7880c5f560..0a240d40e7 100644 --- a/modules/sdk-coin-stx/test/fixtures.ts +++ b/modules/sdk-coin-stx/test/fixtures.ts @@ -10,15 +10,15 @@ export const txExplainedTransfer = { }; export const txForExplainContract = - '80800000000400164247d6f2b425ac5771423ae6c80c754f7172b0000000000000000000000000000000b4000009d038cfc4db2b0fa3d590b89363a762897fef5c7385b88bc4d4e6fb667f062c293b00b8a6a1750e30b4c90bb539df81cdd522f46ff66da1c7af1c66803352b5030200000000021a000000000000000000000000000000000000000005706f782d3209737461636b2d73747800000001000000000000000000000000000000007b'; + '80800000000400164247d6f2b425ac5771423ae6c80c754f7172b0000000000000000000000000000000b4000037980c4fe5607724d9d6cbd320d38cea5931cc940ac23b6e36316cf5f077a0ec260e7c5d3916d0e375d4c68e94e4779ad8b7226c34c71fd453b818066a5a30ac030200000000021a000000000000000000000000000000000000000005706f782d3309737461636b2d737478000000040100000000000000000000000017d7840005163248e7aa6879968d241f3e5152d9f2796994d96c090a0c00000002096861736862797465730200000009736f6d652d686173680776657273696f6e020000000101'; export const txExplainedContract = { - id: 'a1289c2a790240ee07641958e6982640ffab7cfe3ca1581c91d5b7f94e874cec', + id: '686864ede927cc05a16a842951d96e6e4a201432f33ab01d58e952ef0e958832', fee: '180', contractAddress: 'ST000000000000000000002AMW42H', - contractName: 'pox-2', + contractName: 'pox-3', functionName: 'stack-stx', - functionArgs: [{ type: 0, value: '123' }], + functionArgs: [{ type: 1, value: '400000000' }], }; export const unsignedTxForExplainTransfer = diff --git a/modules/sdk-coin-stx/test/unit/resources.ts b/modules/sdk-coin-stx/test/unit/resources.ts index 54c5f64b8d..14075a5400 100644 --- a/modules/sdk-coin-stx/test/unit/resources.ts +++ b/modules/sdk-coin-stx/test/unit/resources.ts @@ -125,20 +125,20 @@ export const MULTI_SIG_SIGNED_TRANSACTION = // contract call export const CONTRACT_ADDRESS = 'ST000000000000000000002AMW42H'; -export const CONTRACT_NAME = 'pox-2'; +export const CONTRACT_NAME = 'pox-3'; export const CONTRACT_FUNCTION_NAME = 'stack-stx'; export const UNSIGNED_SELF_STACK_CONTRACT_CALL = - '80800000000400164247d6f2b425ac5771423ae6c80c754f7172b0000000000000000000000000000000b4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030200000000021a000000000000000000000000000000000000000005706f782d3209737461636b2d737478000000040100000000000000000000000017d784000c00000002096861736862797465730200000009736f6d652d686173680776657273696f6e020000000101010000000000000000000000000000ce400100000000000000000000000000000002'; + '80800000000400164247d6f2b425ac5771423ae6c80c754f7172b0000000000000000000000000000000b4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030200000000021a000000000000000000000000000000000000000005706f782d3309737461636b2d737478000000040100000000000000000000000017d784000c00000002096861736862797465730200000009736f6d652d686173680776657273696f6e020000000101010000000000000000000000000000ce400100000000000000000000000000000002'; export const SIGNED_SELF_STACK_CONTRACT_CALL = - '80800000000400164247d6f2b425ac5771423ae6c80c754f7172b0000000000000000000000000000000b4000049311419f02d53453124082f2abca4c919f0d731377f356f1a83cd99309af7f916e09a72206398088de63e89d431c20bebb12a83a83f5e0cfaf91e2f64259b17030200000000021a000000000000000000000000000000000000000005706f782d3209737461636b2d737478000000040100000000000000000000000017d784000c00000002096861736862797465730200000009736f6d652d686173680776657273696f6e020000000101010000000000000000000000000000ce400100000000000000000000000000000002'; + '80800000000400164247d6f2b425ac5771423ae6c80c754f7172b0000000000000000000000000000000b40001710f7ede3c8a199c5303fe42f3b2e984db28b60fd288257773287f595c8142ba43a2dc3c60cf332c9f123ceffd24a26e0fe8d08a1fd36bc3cba118a4c436f397030200000000021a000000000000000000000000000000000000000005706f782d3309737461636b2d737478000000040100000000000000000000000017d784000c00000002096861736862797465730200000009736f6d652d686173680776657273696f6e020000000101010000000000000000000000000000ce400100000000000000000000000000000002'; export const UNSIGNED_CONTRACT_CALL = - '80800000000400164247d6f2b425ac5771423ae6c80c754f7172b0000000000000000000000000000000b4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030200000000021a000000000000000000000000000000000000000005706f782d3209737461636b2d737478000000040100000000000000000000000017d7840005163248e7aa6879968d241f3e5152d9f2796994d96c0a01000000000000000000000000000000c80a0c00000002096861736862797465730200000009736f6d652d686173680776657273696f6e020000000101'; + '80800000000400164247d6f2b425ac5771423ae6c80c754f7172b0000000000000000000000000000000b4000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000030200000000021a000000000000000000000000000000000000000005706f782d3309737461636b2d737478000000040100000000000000000000000017d7840005163248e7aa6879968d241f3e5152d9f2796994d96c0a01000000000000000000000000000000c80a0c00000002096861736862797465730200000009736f6d652d686173680776657273696f6e020000000101'; export const SIGNED_CONTRACT_WITH_ARGS = - '80800000000400164247d6f2b425ac5771423ae6c80c754f7172b0000000000000000000000000000000b400016bb7df3057794db2f86482ec0b170a4eb3ed0d13ce339f1bb3e89f94702cb5a95679f6d917f82de0e2c6860fe623155b2681ea95099b1f19af704a1d305a1248030200000000021a000000000000000000000000000000000000000005706f782d3209737461636b2d737478000000040100000000000000000000000017d7840005163248e7aa6879968d241f3e5152d9f2796994d96c090a0c00000002096861736862797465730200000009736f6d652d686173680776657273696f6e020000000101'; + '80800000000400164247d6f2b425ac5771423ae6c80c754f7172b0000000000000000000000000000000b4000037980c4fe5607724d9d6cbd320d38cea5931cc940ac23b6e36316cf5f077a0ec260e7c5d3916d0e375d4c68e94e4779ad8b7226c34c71fd453b818066a5a30ac030200000000021a000000000000000000000000000000000000000005706f782d3309737461636b2d737478000000040100000000000000000000000017d7840005163248e7aa6879968d241f3e5152d9f2796994d96c090a0c00000002096861736862797465730200000009736f6d652d686173680776657273696f6e020000000101'; export const SIGNED_CONTRACT_CALL = - '80800000000400164247d6f2b425ac5771423ae6c80c754f7172b0000000000000000000000000000000b40000d6b8ad0ea039947d60dbbabbd48a487321c16e839d2e43677e2a0ef976c7c6bb2d8b55e51f55dca9f14b4164750e106f22250c15415fb6b20b029a0bc17e56b8030200000000021a000000000000000000000000000000000000000005706f782d3209737461636b2d737478000000010a000000000000000000000000000000007b'; + '80800000000400164247d6f2b425ac5771423ae6c80c754f7172b0000000000000000000000000000000b40001d140984651d7b3339c85df78cc59c176237579421112da4eb45ce75803d87176155d48c63afd595a3469b0b2b2a9f81e4806d7ce9b9acdc59d4af23356d37b84030200000000021a000000000000000000000000000000000000000005706f782d3309737461636b2d737478000000010a000000000000000000000000000000007b'; export const MULTI_SIG_CONTRACT_CALL = - '808000000004012fe507c09dbb23c3b7e5d166c81fc4b87692510b000000000000000000000000000000b40000000302001dc3ebb5f91bc34e97b53037f191bed851bc1dfe7239e1c8536a58a52cbb7201109d4ad6e0cd6f2906cf238670b0d86020e6082694991f3243f8f1c797d8460e02018e78a7f3f2a89929f3d7dfa65a5cf1774dfc9fd5500ebb7a606a9f54a47ce8c02febbacd6f15fa741c9e49cb13999f28ca57850f769801a40728ab244020427b00038e3c4529395611be9abf6fa3b6987e81d402385e3d605a073f42f407565a4a3d0002030200000000021a000000000000000000000000000000000000000005706f782d3209737461636b2d737478000000010a000000000000000000000000000000007b'; + '808000000004012fe507c09dbb23c3b7e5d166c81fc4b87692510b000000000000000000000000000000b400000003020037aed42ad2597983a6803c8122d9bca4c6f3566fc078fe2bbfdcf0d5f7eae68121e575eb94704c0c6cb40a5b1e7a8458bba45ffd1a54408c8efa4bcf0c0a818f02011478d5f323ea1da203fc2661aeb363f66e5b19e4e9d1ed80de99054372d573cd0942fad4e9f5cfba3e8086bb75f5def6c2220afb1feae11f249f334304831f7b00038e3c4529395611be9abf6fa3b6987e81d402385e3d605a073f42f407565a4a3d0002030200000000021a000000000000000000000000000000000000000005706f782d3309737461636b2d737478000000010a000000000000000000000000000000007b'; // contract call with memo nonce 45n, export const SEND_MANY_CONTRACT_ADDRESS_WITH_MEMO = 'ST3F1X4QGV2SM8XD96X45M6RTQXKA1PZJZZCQAB4B'; diff --git a/modules/sdk-coin-stx/test/unit/transactionBuilder/contractBuilder.ts b/modules/sdk-coin-stx/test/unit/transactionBuilder/contractBuilder.ts index 6239d1f6f8..cfc4896bda 100644 --- a/modules/sdk-coin-stx/test/unit/transactionBuilder/contractBuilder.ts +++ b/modules/sdk-coin-stx/test/unit/transactionBuilder/contractBuilder.ts @@ -374,7 +374,7 @@ describe('Stacks: Contract Builder', function () { }); it('a contract call with an invalid contract name', () => { const builder = initTxBuilder(); - assert.throws(() => builder.contractName('test'), /Only pox-2 and send-many-memo contracts supported/); + assert.throws(() => builder.contractName('pox-2'), /Only pox-3 and send-many-memo contracts supported/); }); it('a contract call with an invalid contract function name', () => { const builder = initTxBuilder();