|
1 | 1 | import { AxiosHeaders } from "axios"; |
2 | 2 | import { assert } from "chai"; |
3 | 3 | import { Address } from "../address"; |
| 4 | +import { loadTestWallet } from "../testutils"; |
4 | 5 | import { MockQuery } from "../testutils/dummyQuery"; |
| 6 | +import { TransactionComputer } from "../transactionComputer"; |
5 | 7 | import { ApiNetworkProvider } from "./apiNetworkProvider"; |
6 | 8 | import { INetworkProvider, ITransactionNext } from "./interface"; |
7 | 9 | import { ProxyNetworkProvider } from "./proxyNetworkProvider"; |
@@ -192,6 +194,42 @@ describe("test network providers on devnet: Proxy and API", function () { |
192 | 194 | proxyResponse.decimals = 0; |
193 | 195 | } |
194 | 196 |
|
| 197 | + it("should be able to send transaction with relayer", async function () { |
| 198 | + this.timeout(5000); |
| 199 | + const grace = await loadTestWallet("grace"); |
| 200 | + const relayer = await loadTestWallet("alice"); |
| 201 | + const transactionComputer = new TransactionComputer(); |
| 202 | + const nonce = (await apiProvider.getAccount(grace.getAddress())).nonce; |
| 203 | + const transaction: ITransactionNext = { |
| 204 | + receiver: grace.getAddress().bech32(), |
| 205 | + sender: grace.getAddress().bech32(), |
| 206 | + gasPrice: BigInt(1000000000), |
| 207 | + gasLimit: BigInt(150000), |
| 208 | + chainID: "D", |
| 209 | + version: 1, |
| 210 | + nonce: BigInt(nonce), |
| 211 | + relayer: relayer.getAddress(), |
| 212 | + value: BigInt(1), |
| 213 | + senderUsername: "", |
| 214 | + receiverUsername: "", |
| 215 | + guardian: "", |
| 216 | + guardianSignature: new Uint8Array(), |
| 217 | + options: 0, |
| 218 | + data: new Uint8Array(), |
| 219 | + signature: new Uint8Array(), |
| 220 | + relayerSignature: new Uint8Array(), |
| 221 | + }; |
| 222 | + transaction.signature = await grace.signer.sign(transactionComputer.computeBytesForSigning(transaction)); |
| 223 | + |
| 224 | + const buffer = transactionComputer.computeBytesForSigning(transaction); |
| 225 | + |
| 226 | + const signature = await relayer.signer.sign(Buffer.from(buffer)); |
| 227 | + transaction.relayerSignature = signature; |
| 228 | + |
| 229 | + const hash = await proxyProvider.sendTransaction(transaction); |
| 230 | + assert.isNotNull(hash); |
| 231 | + }); |
| 232 | + |
195 | 233 | it("should be able to send transaction(s)", async function () { |
196 | 234 | this.timeout(5000); |
197 | 235 |
|
|
0 commit comments