|
1 | 1 | import { beforeAll, describe, expect, test } from "bun:test";
|
2 | 2 | import assert from "node:assert";
|
3 |
| -import type { Address } from "thirdweb"; |
| 3 | +import { type Address, stringToHex } from "thirdweb"; |
4 | 4 | import { zeroAddress } from "viem";
|
5 | 5 | import type { ApiError } from "../../../sdk/dist/thirdweb-dev-engine.cjs";
|
6 | 6 | import { CONFIG } from "../config";
|
@@ -69,6 +69,98 @@ describe("Write Tests", () => {
|
69 | 69 | expect(writeTransactionStatus.minedAt).toBeDefined();
|
70 | 70 | });
|
71 | 71 |
|
| 72 | + test.only("Write to a contract with untyped args", async () => { |
| 73 | + const res = await engine.deploy.deployNftDrop( |
| 74 | + CONFIG.CHAIN.id.toString(), |
| 75 | + backendWallet, |
| 76 | + { |
| 77 | + contractMetadata: { |
| 78 | + name: "test token", |
| 79 | + platform_fee_basis_points: 0, |
| 80 | + platform_fee_recipient: zeroAddress, |
| 81 | + symbol: "TT", |
| 82 | + trusted_forwarders: [], |
| 83 | + seller_fee_basis_points: 0, |
| 84 | + fee_recipient: zeroAddress, |
| 85 | + }, |
| 86 | + }, |
| 87 | + ); |
| 88 | + |
| 89 | + expect(res.result.queueId).toBeDefined(); |
| 90 | + assert(res.result.queueId, "queueId must be defined"); |
| 91 | + expect(res.result.deployedAddress).toBeDefined(); |
| 92 | + const nftDropContractAddress = res.result.deployedAddress; |
| 93 | + |
| 94 | + if (!nftDropContractAddress) { |
| 95 | + throw new Error("nftDropContractAddress must be defined"); |
| 96 | + } |
| 97 | + |
| 98 | + const transactionStatus = await pollTransactionStatus( |
| 99 | + engine, |
| 100 | + res.result.queueId, |
| 101 | + true, |
| 102 | + ); |
| 103 | + |
| 104 | + expect(transactionStatus.minedAt).toBeDefined(); |
| 105 | + const writeRes = await engine.contract.write( |
| 106 | + CONFIG.CHAIN.id.toString(), |
| 107 | + nftDropContractAddress, |
| 108 | + backendWallet, |
| 109 | + { |
| 110 | + functionName: "setApprovalForAll", |
| 111 | + args: [ |
| 112 | + "0x1234567890123456789012345678901234567890", |
| 113 | + "true", // string instead of bool |
| 114 | + ], |
| 115 | + }, |
| 116 | + ); |
| 117 | + |
| 118 | + expect(writeRes.result.queueId).toBeDefined(); |
| 119 | + |
| 120 | + const writeTransactionStatus = await pollTransactionStatus( |
| 121 | + engine, |
| 122 | + writeRes.result.queueId, |
| 123 | + true, |
| 124 | + ); |
| 125 | + |
| 126 | + expect(writeTransactionStatus.minedAt).toBeDefined(); |
| 127 | + |
| 128 | + const writeRes2 = await engine.contract.write( |
| 129 | + CONFIG.CHAIN.id.toString(), |
| 130 | + nftDropContractAddress, |
| 131 | + backendWallet, |
| 132 | + { |
| 133 | + functionName: "setClaimConditions", |
| 134 | + args: [ |
| 135 | + // stringified array of structs |
| 136 | + JSON.stringify([ |
| 137 | + { |
| 138 | + startTimestamp: "0", |
| 139 | + maxClaimableSupply: "100000", |
| 140 | + supplyClaimed: "0", |
| 141 | + quantityLimitPerWallet: "10", |
| 142 | + merkleRoot: stringToHex("", { size: 32 }), |
| 143 | + pricePerToken: "0", |
| 144 | + currency: zeroAddress, |
| 145 | + metadata: "", |
| 146 | + }, |
| 147 | + ]), |
| 148 | + "false", |
| 149 | + ], |
| 150 | + }, |
| 151 | + ); |
| 152 | + |
| 153 | + expect(writeRes2.result.queueId).toBeDefined(); |
| 154 | + |
| 155 | + const writeTransactionStatus2 = await pollTransactionStatus( |
| 156 | + engine, |
| 157 | + writeRes2.result.queueId, |
| 158 | + true, |
| 159 | + ); |
| 160 | + |
| 161 | + expect(writeTransactionStatus2.minedAt).toBeDefined(); |
| 162 | + }); |
| 163 | + |
72 | 164 | test("Write to a contract with function signature", async () => {
|
73 | 165 | const writeRes = await engine.contract.write(
|
74 | 166 | CONFIG.CHAIN.id.toString(),
|
|
0 commit comments