diff --git a/packages/transactions/commitment-tx/lib/commitmentTx.ts b/packages/transactions/commitment-tx/lib/commitmentTx.ts index ec9940da..33e039eb 100644 --- a/packages/transactions/commitment-tx/lib/commitmentTx.ts +++ b/packages/transactions/commitment-tx/lib/commitmentTx.ts @@ -3,6 +3,7 @@ import { ObservationEntity } from '@rosen-bridge/observation-extractor'; import { RWTRepo } from '@rosen-bridge/rwt-repo'; import { blake2b } from 'blakejs'; import * as ergoLib from 'ergo-lib-wasm-nodejs'; +import { bigIntToUint8Array, hexToUint8Array } from './utils'; export class CommitmentTx { private static _instance?: CommitmentTx; @@ -11,7 +12,9 @@ export class CommitmentTx { private constructor( private permitAddress: string, + private permitBoxValue: bigint, private commitmentAddress: string, + private commitmentBoxValue: bigint, private rwt: string, private txFee: string, private rwtRepo: RWTRepo, @@ -34,7 +37,9 @@ export class CommitmentTx { */ static init = ( permitAddress: string, + permitBoxValue: bigint, commitmentAddress: string, + commitmentBoxValue: bigint, rwt: string, txFee: string, rwtRepo: RWTRepo, @@ -46,7 +51,9 @@ export class CommitmentTx { CommitmentTx._instance = new CommitmentTx( permitAddress, + permitBoxValue, commitmentAddress, + commitmentBoxValue, rwt, txFee, rwtRepo, @@ -80,8 +87,10 @@ export class CommitmentTx { newBuilder = (observation: ObservationEntity): CommitmentTxBuilder => { return new CommitmentTxBuilder( this.permitAddress, + this.permitBoxValue, this.permitScriptHash, this.commitmentAddress, + this.commitmentBoxValue, this.rwt, this.txFee, this.rwtRepo, @@ -101,8 +110,10 @@ export class CommitmentTxBuilder { constructor( private permitAddress: string, + private permitBoxValue: bigint, private permitScriptHash: string, private commitmentAddress: string, + private commitmentBoxValue: bigint, private rwt: string, private txFee: string, private rwtRepo: RWTRepo, @@ -201,6 +212,123 @@ export class CommitmentTxBuilder { this.logger?.debug(`new value set for height=[${this.height}]`); return this; }; + + /** + * creates permit box + * + * @private + * @param {bigint} rwtCount + * @return {ergoLib.ErgoBoxCandidate} + * @memberof CommitmentTxBuilder + */ + private createPermitBox = (rwtCount: bigint): ergoLib.ErgoBoxCandidate => { + const boxBuilder = new ergoLib.ErgoBoxCandidateBuilder( + ergoLib.BoxValue.from_i64( + ergoLib.I64.from_str(this.permitBoxValue.toString()) + ), + ergoLib.Contract.pay_to_address( + ergoLib.Address.from_base58(this.permitAddress) + ), + this.height + ); + + boxBuilder.add_token( + ergoLib.TokenId.from_str(this.rwt), + ergoLib.TokenAmount.from_i64(ergoLib.I64.from_str(rwtCount.toString())) + ); + this.logger?.debug( + `rwtCount=[${rwtCount}] rwt tokens added to output permit box` + ); + + boxBuilder.set_register_value( + 4, + ergoLib.Constant.from_coll_coll_byte([hexToUint8Array(this.wid)]) + ); + + return boxBuilder.build(); + }; + + /** + * creates commitment box + * + * @private + * @return {ergoLib.ErgoBoxCandidate} + * @memberof CommitmentTxBuilder + */ + private createCommitmentBox = (): ergoLib.ErgoBoxCandidate => { + const boxBuilder = new ergoLib.ErgoBoxCandidateBuilder( + ergoLib.BoxValue.from_i64( + ergoLib.I64.from_str(this.commitmentBoxValue.toString()) + ), + ergoLib.Contract.pay_to_address( + ergoLib.Address.from_base58(this.commitmentAddress) + ), + this.height + ); + + boxBuilder.add_token( + ergoLib.TokenId.from_str(this.rwt), + ergoLib.TokenAmount.from_i64( + ergoLib.I64.from_str(this.rwtRepo.getCommitmentRwtCount().toString()) + ) + ); + this.logger?.debug( + `added rwt token to commitment box with amount=[${this.rwtRepo.getCommitmentRwtCount()}]` + ); + + boxBuilder.set_register_value( + 4, + ergoLib.Constant.from_coll_coll_byte([hexToUint8Array(this.wid)]) + ); + + boxBuilder.set_register_value( + 5, + ergoLib.Constant.from_coll_coll_byte([hexToUint8Array(this.eventId)]) + ); + + boxBuilder.set_register_value( + 6, + ergoLib.Constant.from_byte_array(this.eventDigest) + ); + this.logger?.debug( + `output commitment box R6 register value: eventDigest=[${Buffer.from( + this.eventDigest + ).toString('hex')}]` + ); + + boxBuilder.set_register_value( + 7, + ergoLib.Constant.from_byte_array(hexToUint8Array(this.permitScriptHash)) + ); + + return boxBuilder.build(); + }; + + /** + * calculates event digest for this instance's observation and wid + * + * @readonly + * @private + * @memberof CommitmentTxBuilder + */ + private get eventDigest() { + const content = Buffer.concat([ + Buffer.from(this.observation.sourceTxId), + Buffer.from(this.observation.fromChain), + Buffer.from(this.observation.toChain), + Buffer.from(this.observation.fromAddress), + Buffer.from(this.observation.toAddress), + bigIntToUint8Array(BigInt(this.observation.amount)), + bigIntToUint8Array(BigInt(this.observation.bridgeFee)), + bigIntToUint8Array(BigInt(this.observation.networkFee)), + Buffer.from(this.observation.sourceChainTokenId), + Buffer.from(this.observation.targetChainTokenId), + Buffer.from(this.observation.sourceBlockId), + bigIntToUint8Array(BigInt(this.observation.height)), + Buffer.from(this.wid, 'hex'), + ]); + return blake2b(content, undefined, 32); + } } /** diff --git a/packages/transactions/commitment-tx/lib/utils.ts b/packages/transactions/commitment-tx/lib/utils.ts new file mode 100644 index 00000000..ab4b8498 --- /dev/null +++ b/packages/transactions/commitment-tx/lib/utils.ts @@ -0,0 +1,20 @@ +/** + * converts bigint to Uint8Array + * + * @param {bigint} num + * @return {Uint8Array} + */ +export const bigIntToUint8Array = (num: bigint): Uint8Array => { + const b = new ArrayBuffer(8); + new DataView(b).setBigUint64(0, num); + return new Uint8Array(b); +}; + +/** + * converts a hex string to Uint8Array bytes + * + * @param {string} hex + * @return {Uint8Array} + */ +export const hexToUint8Array = (hex: string): Uint8Array => + Uint8Array.from(Buffer.from(hex, 'hex')); diff --git a/packages/transactions/commitment-tx/tests/commitmentTx.spec.ts b/packages/transactions/commitment-tx/tests/commitmentTx.spec.ts index 02023977..905228dc 100644 --- a/packages/transactions/commitment-tx/tests/commitmentTx.spec.ts +++ b/packages/transactions/commitment-tx/tests/commitmentTx.spec.ts @@ -51,7 +51,9 @@ describe('CommitmentTx', () => { properties and passed arguments`, async () => { CommitmentTx.init( commitmentTxParams.permitAddress, + commitmentTxParams.permitBoxValue, commitmentTxParams.commitmentAddress, + commitmentTxParams.commitmentBoxValue, commitmentTxParams.rwt, commitmentTxParams.txFee, commitmentTxParams.rwtRepo @@ -63,12 +65,18 @@ describe('CommitmentTx', () => { expect(commitmentTxBuilder['permitAddress']).toEqual( commitmentTxParams.permitAddress ); + expect(commitmentTxBuilder['permitBoxValue']).toEqual( + commitmentTxParams.permitBoxValue + ); expect(commitmentTxBuilder['permitScriptHash']).toEqual( commitmentTxParams.permitScriptHash ); expect(commitmentTxBuilder['commitmentAddress']).toEqual( commitmentTxParams.commitmentAddress ); + expect(commitmentTxBuilder['commitmentBoxValue']).toEqual( + commitmentTxParams.commitmentBoxValue + ); expect(commitmentTxBuilder['rwt']).toEqual(commitmentTxParams.rwt); expect(commitmentTxBuilder['txFee']).toEqual(commitmentTxParams.txFee); expect(commitmentTxBuilder['rwtRepo']).toEqual( @@ -90,8 +98,10 @@ describe('CommitmentTxBuilder', () => { commitmentTxBuilder = new CommitmentTxBuilder( commitmentTxParams.permitAddress, + commitmentTxParams.permitBoxValue, permitScriptHash, commitmentTxParams.commitmentAddress, + commitmentTxParams.commitmentBoxValue, commitmentTxParams.rwt, commitmentTxParams.txFee, commitmentTxParams.rwtRepo, @@ -271,4 +281,118 @@ describe('CommitmentTxBuilder', () => { expect(commitmentTxBuilder['height']).toEqual(newHeight); }); }); + + describe('createPermitBox', () => { + /** + * @target should create permit box from instance's properties + * @dependencies + * - None + * @scenario + * - call setWid + * - call setCreationHeight + * - call createPermitBox with a value for rwtCount + * - check returned box to have the right properties set + * @expected + * - returned box should have the right properties set + */ + it(`should create permit box from instance's properties`, async () => { + const r4 = ergoLib.Constant.decode_from_base16( + samplePermitBoxes[0].additionalRegisters.R4 + ).to_coll_coll_byte(); + const wid = Buffer.from(r4[0]).toString('hex'); + commitmentTxBuilder.setWid(wid); + + const height = 100; + commitmentTxBuilder.setCreationHeight(height); + + const rwtCount = 20n; + const permitBox = commitmentTxBuilder['createPermitBox'](rwtCount); + + expect(permitBox.value().as_i64().to_str()).toEqual( + commitmentTxBuilder['permitBoxValue'].toString() + ); + + expect( + ergoLib.Address.recreate_from_ergo_tree( + permitBox.ergo_tree() + ).to_base58(ergoLib.NetworkPrefix.Mainnet) + ).toEqual(commitmentTxBuilder['permitAddress']); + + expect(permitBox.creation_height()).toEqual( + commitmentTxBuilder['height'] + ); + + expect(permitBox.tokens().get(0).id().to_str()).toEqual( + commitmentTxBuilder['rwt'] + ); + expect(permitBox.tokens().get(0).amount().as_i64().to_str()).toEqual( + rwtCount.toString() + ); + + expect(permitBox.register_value(4)?.to_coll_coll_byte()).toEqual(r4); + }); + }); + + describe('createCommitmentBox', () => { + /** + * @target should create a commitment box from instance's properties + * @dependencies + * - None + * @scenario + * - call setWid + * - call setCreationHeight + * - call createCommitmentBox + * - check returned box to have the right properties set + * @expected + * - returned box should have the right properties set + */ + it(`should create a commitment box from instance's properties`, async () => { + const r4 = ergoLib.Constant.decode_from_base16( + samplePermitBoxes[0].additionalRegisters.R4 + ).to_coll_coll_byte(); + const wid = Buffer.from(r4[0]).toString('hex'); + commitmentTxBuilder.setWid(wid); + + const height = 100; + commitmentTxBuilder.setCreationHeight(height); + + const commitmentBox = commitmentTxBuilder['createCommitmentBox'](); + + expect(commitmentBox.value().as_i64().to_str()).toEqual( + commitmentTxBuilder['commitmentBoxValue'].toString() + ); + + expect( + ergoLib.Address.recreate_from_ergo_tree( + commitmentBox.ergo_tree() + ).to_base58(ergoLib.NetworkPrefix.Mainnet) + ).toEqual(commitmentTxBuilder['commitmentAddress']); + + expect(commitmentBox.creation_height()).toEqual( + commitmentTxBuilder['height'] + ); + + expect(commitmentBox.tokens().get(0).id().to_str()).toEqual( + commitmentTxBuilder['rwt'] + ); + expect(commitmentBox.tokens().get(0).amount().as_i64().to_str()).toEqual( + commitmentTxBuilder['rwtRepo'].getCommitmentRwtCount().toString() + ); + + expect(commitmentBox.register_value(4)?.to_coll_coll_byte()).toEqual(r4); + expect( + Buffer.from( + commitmentBox.register_value(5)!.to_coll_coll_byte()[0] + ).toString('hex') + ).toEqual(commitmentTxBuilder['eventId']); + expect(commitmentBox.register_value(6)?.to_byte_array()).toEqual( + commitmentTxBuilder['eventDigest'] + ); + expect( + Buffer.from(commitmentBox.register_value(7)!.to_byte_array()).toString( + 'hex' + ) + ).toEqual(commitmentTxBuilder['permitScriptHash']); + }); + }); }); diff --git a/packages/transactions/commitment-tx/tests/commitmentTxTestData.ts b/packages/transactions/commitment-tx/tests/commitmentTxTestData.ts index 8c1d0d4d..ccf2565e 100644 --- a/packages/transactions/commitment-tx/tests/commitmentTxTestData.ts +++ b/packages/transactions/commitment-tx/tests/commitmentTxTestData.ts @@ -1,14 +1,85 @@ +import JsonBigInt from '@rosen-bridge/json-bigint'; import { ObservationEntity } from '@rosen-bridge/observation-extractor'; import { RWTRepo } from '@rosen-bridge/rwt-repo'; import { ErgoNetworkType } from '@rosen-bridge/scanner'; import { blake2b } from 'blakejs'; import * as ergoLib from 'ergo-lib-wasm-nodejs'; +export const sampleRwtRepoboxInfo = { + boxId: 'e95d2f7eab31c379345a5325949509789f690f90bac6f7c56c6e3c2a958869a2', + transactionId: + 'c85647df07f4ea14bf4635b1650c6c313366b6ca22a28212a30f82ed658d067c', + blockId: '69521f157cd78e9962e7aa077cf973c2ce33dd534bec84ce35c7e6f092763519', + value: 1100000, + index: 1, + globalIndex: 31753615, + creationHeight: 1068081, + settlementHeight: 1068083, + ergoTree: + '102c040004000e20c691b75b137752e0fcbd590b9942ca2455f528db8e553b8632988c555eef2bc40e20793d6c566f238cd234176f7007b1e50c2e5ae4367b668351451ec6c9e9e97ca901010402040204040404040004010402040404000e20aedb01e6a2594d7dacf6f63b2f3247e3b1ecf01409960758934d2fb4c3004f070401040204020406040a040004000400040805000400010104020402040004000400040004020402040004000402040204000400040004000406d805d601b2a5730000d602db63087201d603b27202730100d6048c720301d6057302959372047303d17304d811d606db6308a7d607b27206730500d6088c720702d609b27202730600d60a8c720902d60bb27202730700d60c8c720b02d60db27206730800d60e8c720d02d60fe4c6a70611d610b27206730900d6118c720d01d6129683060193c27201c2a793e4c672010611720f9372048c721001938c7203028c721002938c7209018c720701938c720b017211d613e4c6a70511d614b17213d615e4c672010511d616b1721595917208720ad805d617e5c672010704730ad618997208720ad619b2a5730b00d61ab2a5730c00d61b96830401721293721899720c720e938cb2db63087219730d0002721893cbc27219730e95937217730fd806d61ce4c67201041ad61d9a72147310d61e9972167311d61fc5a7d620b2a5731200d621b2720f731300d196830d01721b93b1721c721d93b4721c7314721ee4c6a7041a93b2721c721e00721f937216721d93b472157315721e721393b27215721e00721893e4c67219041a83010e721f938cb2db6308721a73160001721f93cbc27220720593e4c67220040e721f92c17220b2720f731700959172217318d801d622b2db6308722073190096830201938c7222017211928c7222027221731ad803d61ce4c6a7041ad61db2721c721700d61e9a7217731bd196830801721b93721d8cb2db6308b2a4731c00731d000193e4c67201041a721c93b272157217009ab27213721700721893b47215731e7217b47213731f721793b47215721e7216b47213721e721693e4c67219041a83010e721d938cb2db6308721a73200001721dd803d617e4c672010704d61899720a7208d619b27213721700d19683040172129383010eb2e4c6a7041a721700e4c6b2a4732100041a93721899720e720c959172197218d801d61a9a72177322968304019372199ab27215721700721893e4c6a7041ae4c67201041a93b4721373237217b472157324721793b47213721a7214b47215721a7214d804d61ae4c6a7041ad61be4c67201041ad61c9a72177325d61d997214732696830601937219721893b4721a73277217b4721b7328721793b4721a721c7214b4721b7217721d93b4721373297217b47215732a721793b47213721c7214b472157217721d93cbc2b2a4732b007205', + address: + '5qwczr7KdspNWq5dg6FZJZSDJ9YGcYDsCVi53E6M9gPamGjQTee9Zp5HLbJXQvWJ49ksh9Ao9YK3VcjHZjVVN2rP74YoYUwCo1xY25jJQRvmqF7tMJdUYAWxB1mg3U5xrcYy6oKhev7TNtnzgWW9831r6yx5B9jmBDj7FoC36s8y7DeKQPsG1HaZLBnyLyR8iKWRUeASSFg8QXMksZdE1ZgsnF218aEmjbeEmnj2DcjwQgatAhJKRzN24PNStzk2D41UL3Xe5FSTyVw7p3u6vXim2hDSKj3qAcGboaVv9SKayhbezzdYxiuKodcyggY63H39cUhgYFwHWahpNhVZBjWP4Q4yAm7ebxjfF2RFFjW8njZNGS1SERo5dqRZZcQ79faKeXmNkZ47TnHB8qQHhwxg4BVEWppfWUyoTbSFdBHGxZufej126i8P3QZaTT7Wi28iC8HA9xTj8ZT7A5facme2TGCFjVucYjRzPLd8PXHqjPq9hoAvUjRQi9pV6uppFppuhAPoNrCyi8JA2yTEcohaokoYLmRgp86QKW4AgCADJKhTczSoHz5wsDbbzTsGeoajPwPEosM2dDazqBobiuhnX5x1m4iegB4QWYJkeNWxPdXCWgxK3fTqGDhKdS6jja9nKUMtixmaLPrwLF22S61NcifoxwEfgTKT11UnmtGMCXkkTDkcreuGUkhZMAG7Kqy3MeuMvJin8f6fb6Mivr6A6ad6rqKChyPiFWr2YaeVbdeidGbQrW9FfjvYhRrTkwBBMcRac6eazjmVqYbe9Mqy1znj8t5PpdyndoGZHPmSbYo9ZF3ZTbjh9qT3kKPQ6TVc772NGyrYWaupPsbk7MJYTBZ5WWtnHbxQyqSLAEmeq4csX3pr5kcgQCoqkqY3UkgoFRBjsTDFp61FiAc6KdivhAh4AvWB5jAYKfqps6XwgQrCRqifD8XN6k6k41Cs6UeMU5FzH4fMqEwBTDyAsCigVaY7gz3eMdDrARc1Ec23rEYepqtuBeWe2ienoMgYazHwp27DvinbAyppFziYmf1n898UXpNqsD5ctyZxQ54n67mEXUAuYq7nJMEsTQpYSX9P4dh6qP9geDbYRbFwpN27gJG5HwqwhFwk1n4ytVxVrc7nHqUe86c5gPXb1DZTgJc9YC9b3yQhE6gcNk83Yn8vkrHvHXPE7wgzxQHgV1iMBtk8DkoFCBbHcd3X4MTskaSNKYcWgx4QPSf2GAg2xcsgRePe6ZKRuRLqoZ8dJKyZRc911UUxkY7qd4ZaBrp8ymmWy2s3mjbN3CY9uqXTLTdokNVUzdvAcrC8SKUAqbX567RN9TcuE5FmagD7RFpmy6eVME1MWSvdscheeoXWcvMCYPwVAvotnFrsypXmnZHXgEdNLQVsk19iNQKYG7Lxu51msGC7gKmVGaiifzrB', + assets: [ + { + tokenId: + '32ee5d947cfe8db5480157ffa566b9b7d9faf41fa145c9d00628c7c1599878f6', + index: 0, + amount: 1, + name: 'rptconfRWTRepoV1', + decimals: 0, + type: 'EIP-004', + }, + { + tokenId: + '3825b2b4acaaaba626440113153246c65ddb2e9df406c4a56418b5842c9f839a', + index: 1, + amount: 999900000000, + name: 'rptconfErgoRWTV1', + decimals: 0, + type: 'EIP-004', + }, + { + tokenId: + 'f8fe64d3d94d4eb193ea9d6304646db67bd914ed42cebd3a4f614d9d9de75cf0', + index: 2, + amount: 100000001, + name: 'rptconfRSNV1', + decimals: 3, + type: 'EIP-004', + }, + ], + additionalRegisters: { + R4: { + serializedValue: + '1a0b046572676f20e61a83c5bca59e98c21d925faff5dfc079aa438f21df08702e4c4bf2bada02dc20d050d5e741b9e18bedb81be435f893c8c6ae32ecbbf88554480df8cb9cc0d58920995ca29a94c2290c7648b56e4a84dafda75765c6e793c5cdcd4fba55ff261e9f2090829fb915dba5c834d14b0e1e1387f6c2e4760965b8cd338892e4ad13baab3d20fe83cb8a2843fa6f5751d65e4f957fc622c67ab9211f30b44991a1fb03145c01208abd3c4a0e14dd3632919a758ccfee875cfcf8ea7e0ec85844d4188834fd602d203d36709eb83dc46cc60298ab183a1e4ab1d85363337b951b9494dc1ab1418eb1205589db926e6760d840c919948169a559abcab58ef0d2100126e48f9d2ef1232020aba9cf9df2a03cc07c1adc7515d4d70346c93bd7a250525536a90008f73d289d202228e54299db6c13479c6ced3705df36f2ed0e4e815ed7536ba99be14a13179d', + sigmaType: 'Coll[Coll[SByte]]', + renderedValue: + '[6572676f,e61a83c5bca59e98c21d925faff5dfc079aa438f21df08702e4c4bf2bada02dc,d050d5e741b9e18bedb81be435f893c8c6ae32ecbbf88554480df8cb9cc0d589,995ca29a94c2290c7648b56e4a84dafda75765c6e793c5cdcd4fba55ff261e9f,90829fb915dba5c834d14b0e1e1387f6c2e4760965b8cd338892e4ad13baab3d,fe83cb8a2843fa6f5751d65e4f957fc622c67ab9211f30b44991a1fb03145c01,8abd3c4a0e14dd3632919a758ccfee875cfcf8ea7e0ec85844d4188834fd602d,3d36709eb83dc46cc60298ab183a1e4ab1d85363337b951b9494dc1ab1418eb1,5589db926e6760d840c919948169a559abcab58ef0d2100126e48f9d2ef12320,aba9cf9df2a03cc07c1adc7515d4d70346c93bd7a250525536a90008f73d289d,2228e54299db6c13479c6ced3705df36f2ed0e4e815ed7536ba99be14a13179d]', + }, + R5: { + serializedValue: + '110b0080dac40980dac40980dac40980dac40980dac40980dac40980dac40980dac40980dac40980dac409', + sigmaType: 'Coll[SLong]', + renderedValue: + '[0,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000,10000000]', + }, + R6: { + serializedValue: '1106a09c018c01020a80a8d6b90700', + sigmaType: 'Coll[SLong]', + renderedValue: '[10000,70,1,5,1000000000,0]', + }, + }, + spentTransactionId: null, + mainChain: true, +}; + export const commitmentTxParams = { permitAddress: 'EE7687i4URb4YuSGSQXPCbAjMfN4dUt5Qx8BqKZJiZhDY8fdnSUwcAGqAsqfn1tW1byXB8nDrgkFzkAFgaaempKxfcPtDzAbnu9QfknzmtfnLYHdxPPg7Qtjy7jK5yUpPQ2M4Ps3h5kH57xWDJxcKviEMY11rQnxATjTKTQgGtfzsAPpqsUyT2ZpVYsFzUGJ4nSj4WaDZSU1Hovv6dPkSTArLQSjp38wE72ae6hbNJwXGkqgfBtdVXcZVtnqevw9xUNcE6i942CQ9hVMfbdRobnsaLgsDLQomsh8jLMXqkMde5qH2vGBUqnLKgjxCZaa7vStpPXT5EuzLn9napGwUcbJjgRk69FsRSfCrcydZbYxw4Gnh6ZB9at2USpwL1HdVkHVh8M6Kbw6ppRfeG4JeFsUw33H4sSRk6UPqfuFcRUf7Cec2vmPezXTPT7CXQqEeCjxmWXqfyEQUfnCwpiH5fQ9A8CQ3jTyFhxBTpoGDdtiVCmhqhKxjh9M7gcjpr1dUjGMCWxjir94ejfq24XQrSscrZuUT5NVHTWAkzQ', + permitBoxValue: 2_00_000n, commitmentAddress: 'EE7687i4URb4YuSGSQXPCbAjMfN4dUt5Qx8BqKZJiZhDY8fdnSUwcAGqAsqfn1tW1byXB8nDrgkFzkAFgaaempKxfcPtDzAbnu9QfknzmtfnLYHdxPPg7Qtjy7jK5yUpPQ2M4Ps3h5kH57xWDJxcKviEMY11rQnxATjTKTQgGtfzsAPpqsUyT2ZpVYsFzUGJ4nSj4WaDZSU1Hovv6dPkSTArLQSjp38wE72ae6hbNJwXGkqgfBtdVXcZVtnqevw9xUNcE6i942CQ9hVMfbdRobnsaLgsDLQomsh8jLMXqkMde5qH2vGBUqnLKgjxCZaa7vStpPXT5EuzLn9napGwUcbJjgRk69FsRSfCrcydZbYxw4Gnh6ZB9at2USpwL1HdVkHVh8M6Kbw6ppRfeG4JeFsUw33H4sSRk6UPqfuFcRUf7Cec2vmPezXTPT7CXQqEeCjxmWXqfyEQUfnCwpiH5fQ9A8CQ3jTyFhxBTpoGDdtiVCmhqhKxjh9M7gcjpr1dUjGMCWxjir94ejfq24XQrSscrZuUT5NVHTWAkzQ', + commitmentBoxValue: 4_000_000n, rwt: '3825b2b4acaaaba626440113153246c65ddb2e9df406c4a56418b5842c9f839a', txFee: '50', rwtRepo: new RWTRepo( @@ -32,6 +103,9 @@ commitmentTxParams.permitScriptHash = Buffer.from( 32 ) ).toString('hex'); +commitmentTxParams.rwtRepo['box'] = ergoLib.ErgoBox.from_json( + JsonBigInt.stringify(sampleRwtRepoboxInfo) +); export const observationEntity1 = new ObservationEntity(); observationEntity1.height = 1; @@ -48,7 +122,7 @@ observationEntity1.sourceChainTokenId = 'sourceToken'; observationEntity1.toAddress = 'addr1'; observationEntity1.targetChainTokenId = 'targetToken'; observationEntity1.toChain = 'cardano'; -observationEntity1.requestId = 'reqId2'; +observationEntity1.requestId = '32ab59cd'; export const widBox = { boxId: '2e24776266d16afbf23e7c96ba9c2ffb9bce25ea75d3ed9f2a9a3b2c84bf1655',