|
1 | 1 | import { assert } from "chai"; |
2 | | -import { Abi, U32Value } from "../abi"; |
| 2 | +import { Abi, BigUIntValue, U32Value } from "../abi"; |
3 | 3 | import { Address, Err, Token, TokenTransfer, TransactionsFactoryConfig } from "../core"; |
4 | 4 | import { loadAbiRegistry, loadContractCode } from "../testutils/utils"; |
5 | 5 | import { SmartContractTransactionsFactory } from "./smartContractTransactionsFactory"; |
@@ -44,6 +44,54 @@ describe("test smart contract transactions factory", function () { |
44 | 44 | } |
45 | 45 | }); |
46 | 46 |
|
| 47 | + it("should allow args of type 'TypedValue'", async function () { |
| 48 | + const sender = Address.newFromBech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"); |
| 49 | + const gasLimit = 6000000n; |
| 50 | + const args = [new BigUIntValue(7)]; |
| 51 | + |
| 52 | + const transaction = await factory.createTransactionForDeploy(sender, { |
| 53 | + bytecode: bytecode.valueOf(), |
| 54 | + gasLimit: gasLimit, |
| 55 | + arguments: args, |
| 56 | + }); |
| 57 | + |
| 58 | + const bytecodeHex = Buffer.from(bytecode).toString("hex"); |
| 59 | + assert.deepEqual(transaction.data, Buffer.from(`${bytecodeHex}@0500@0504@07`)); |
| 60 | + }); |
| 61 | + |
| 62 | + it("should allow args of type bytes", async function () { |
| 63 | + const sender = Address.newFromBech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"); |
| 64 | + const gasLimit = 6000000n; |
| 65 | + let args = [Buffer.from([7]), new Uint8Array([7])]; |
| 66 | + const bytecodeHex = Buffer.from(bytecode).toString("hex"); |
| 67 | + |
| 68 | + let transaction = await factory.createTransactionForDeploy(sender, { |
| 69 | + bytecode: bytecode.valueOf(), |
| 70 | + gasLimit: gasLimit, |
| 71 | + arguments: args, |
| 72 | + }); |
| 73 | + |
| 74 | + assert.deepEqual(transaction.data, Buffer.from(`${bytecodeHex}@0500@0504@07@07`)); |
| 75 | + |
| 76 | + args = [new Uint8Array([7]), Buffer.from("6161626261", "hex")]; |
| 77 | + transaction = await factory.createTransactionForDeploy(sender, { |
| 78 | + bytecode: bytecode.valueOf(), |
| 79 | + gasLimit: gasLimit, |
| 80 | + arguments: args, |
| 81 | + }); |
| 82 | + |
| 83 | + assert.deepEqual(transaction.data, Buffer.from(`${bytecodeHex}@0500@0504@07@6161626261`)); |
| 84 | + |
| 85 | + args = [new Uint8Array()]; |
| 86 | + transaction = await factory.createTransactionForDeploy(sender, { |
| 87 | + bytecode: bytecode.valueOf(), |
| 88 | + gasLimit: gasLimit, |
| 89 | + arguments: args, |
| 90 | + }); |
| 91 | + |
| 92 | + assert.deepEqual(transaction.data, Buffer.from(`${bytecodeHex}@0500@0504@`)); |
| 93 | + }); |
| 94 | + |
47 | 95 | it("should create 'Transaction' for deploy", async function () { |
48 | 96 | const sender = Address.newFromBech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th"); |
49 | 97 | const gasLimit = 6000000n; |
|
0 commit comments