diff --git a/tests/e2e/api/transaction_submission.test.ts b/tests/e2e/api/transaction_submission.test.ts index 2c303d356..951f50e18 100644 --- a/tests/e2e/api/transaction_submission.test.ts +++ b/tests/e2e/api/transaction_submission.test.ts @@ -18,6 +18,7 @@ import { TransactionPayloadScript, } from "../../../src/transactions/instances/transactionPayload"; import { SigningScheme } from "../../../src/types"; +import { ALICE_PRIVATE_KEY, BOB_PRIVATE_KEY, TRANSFER_FUNCTION_ADDRESS } from "../../utils/const"; describe("transaction submission", () => { describe("generateTransaction", () => { @@ -26,7 +27,7 @@ describe("transaction submission", () => { const aptos = new Aptos(config); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const rawTxn = await aptos.generateTransaction({ @@ -49,7 +50,7 @@ describe("transaction submission", () => { const aptos = new Aptos(config); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); @@ -57,7 +58,7 @@ describe("transaction submission", () => { sender: alice.accountAddress.toString(), data: { multisigAddress: bob.accountAddress, - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }, @@ -74,14 +75,14 @@ describe("transaction submission", () => { const aptos = new Aptos(config); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const rawTxn = await aptos.generateTransaction({ sender: alice.accountAddress.toString(), data: { - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }, @@ -99,12 +100,12 @@ describe("transaction submission", () => { const aptos = new Aptos(config); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0xc1e06f150f7fa79c1ca0ad0f8d0b26d83abaf1bed0fc31de24b500d81a2ff924", + hexInput: BOB_PRIVATE_KEY, }), }); const rawTxn = await aptos.generateTransaction({ @@ -138,7 +139,7 @@ describe("transaction submission", () => { const aptos = new Aptos(config); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const rawTxn = await aptos.generateTransaction({ @@ -164,7 +165,7 @@ describe("transaction submission", () => { const aptos = new Aptos(config); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); @@ -172,7 +173,7 @@ describe("transaction submission", () => { sender: alice.accountAddress.toString(), data: { multisigAddress: bob.accountAddress, - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }, @@ -192,14 +193,14 @@ describe("transaction submission", () => { const aptos = new Aptos(config); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const rawTxn = await aptos.generateTransaction({ sender: alice.accountAddress.toString(), data: { - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }, @@ -220,12 +221,12 @@ describe("transaction submission", () => { const aptos = new Aptos(config); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0xc1e06f150f7fa79c1ca0ad0f8d0b26d83abaf1bed0fc31de24b500d81a2ff924", + hexInput: BOB_PRIVATE_KEY, }), }); const rawTxn = await aptos.generateTransaction({ @@ -282,7 +283,7 @@ describe("transaction submission", () => { const rawTxn = await aptos.generateTransaction({ sender: alice.accountAddress.toString(), data: { - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }, diff --git a/tests/unit/transaction_builder.test.ts b/tests/unit/transaction_builder.test.ts index b22c4cef9..4c3f2e346 100644 --- a/tests/unit/transaction_builder.test.ts +++ b/tests/unit/transaction_builder.test.ts @@ -30,6 +30,7 @@ import { Network } from "../../src/utils/apiEndpoints"; import { SignedTransaction } from "../../src/transactions/instances/signedTransaction"; import { U64 } from "../../src/bcs/serializable/move-primitives"; import { MoveObject } from "../../src/bcs/serializable/move-structs"; +import { ALICE_PRIVATE_KEY, TRANSFER_FUNCTION_ADDRESS } from "../utils/const"; describe("transaction builder", () => { describe("generate transaction payload", () => { @@ -51,7 +52,7 @@ describe("transaction builder", () => { test("it generates a multi sig transaction payload", async () => { const payload = generateTransactionPayload({ multisigAddress: Account.generate({ scheme: SigningScheme.Ed25519 }).accountAddress, - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [], }); @@ -59,7 +60,7 @@ describe("transaction builder", () => { }); test("it generates an entry function transaction payload", async () => { const payload = generateTransactionPayload({ - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [], }); @@ -71,7 +72,7 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const payload = generateTransactionPayload({ @@ -99,13 +100,13 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const payload = generateTransactionPayload({ multisigAddress: bob.accountAddress, - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }); @@ -122,12 +123,12 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const payload = generateTransactionPayload({ - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }); @@ -145,7 +146,7 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const payload = generateTransactionPayload({ @@ -174,12 +175,12 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const payload = generateTransactionPayload({ - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }); @@ -205,12 +206,12 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const payload = generateTransactionPayload({ - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }); @@ -231,12 +232,12 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const payload = generateTransactionPayload({ - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }); @@ -266,7 +267,7 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const payload = generateTransactionPayload({ @@ -302,7 +303,7 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const payload = generateTransactionPayload({ @@ -336,13 +337,13 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const payload = generateTransactionPayload({ multisigAddress: bob.accountAddress, - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }); @@ -368,7 +369,7 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); @@ -405,7 +406,7 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const payload = generateTransactionPayload({ @@ -440,12 +441,12 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const payload = generateTransactionPayload({ - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }); @@ -477,12 +478,12 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const payload = generateTransactionPayload({ - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }); @@ -515,12 +516,12 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const payload = generateTransactionPayload({ - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }); @@ -537,12 +538,12 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const payload = generateTransactionPayload({ - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }); @@ -563,12 +564,12 @@ describe("transaction builder", () => { const config = new AptosConfig({ network: Network.DEVNET }); const alice = Account.fromPrivateKey({ privateKey: new Ed25519PrivateKey({ - hexInput: "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c", + hexInput: ALICE_PRIVATE_KEY, }), }); const bob = Account.generate({ scheme: SigningScheme.Ed25519 }); const payload = generateTransactionPayload({ - function: "0x1::aptos_account::transfer", + function: TRANSFER_FUNCTION_ADDRESS, type_arguments: [], arguments: [new MoveObject(bob.accountAddress), new U64(1)], }); diff --git a/tests/utils/const.ts b/tests/utils/const.ts new file mode 100644 index 000000000..ce79f3637 --- /dev/null +++ b/tests/utils/const.ts @@ -0,0 +1,3 @@ +export const ALICE_PRIVATE_KEY = "0x5aba8dab1c523be32bd4dafe2cc612f7f8050ce42a3322b60216ef67dc97768c" +export const BOB_PRIVATE_KEY = "0xc1e06f150f7fa79c1ca0ad0f8d0b26d83abaf1bed0fc31de24b500d81a2ff924" +export const TRANSFER_FUNCTION_ADDRESS = "0x1::aptos_account::transfer" \ No newline at end of file