Skip to content

Commit

Permalink
[types] Remove requirement on 0x for input (#113)
Browse files Browse the repository at this point in the history
* [types] Remove requirement on 0x for input

* [address] Update tests to use regular hex output
  • Loading branch information
gregnazario authored Oct 24, 2023
1 parent b65b24b commit c903b3f
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 21 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ All notable changes to the Aptos TypeScript SDK will be captured in this file. T
- Support publish move module API function
- Fix client config not being added to the request
- Support to config a custom client instance
- Changed all Regex based inputs requiring a `0x` to be optional. This is to allow for easier copy/pasting of addresses and keys.

## 0.0.0 (2023-10-18)

Expand Down
8 changes: 4 additions & 4 deletions src/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -665,9 +665,9 @@ export type MoveUint32Type = number;
export type MoveUint64Type = string;
export type MoveUint128Type = string;
export type MoveUint256Type = string;
export type MoveAddressType = `0x${string}`;
export type MoveObjectType = `0x${string}`;
export type MoveStructType = `0x${string}::${string}::${string}`;
export type MoveAddressType = string;
export type MoveObjectType = string;
export type MoveStructType = `${string}::${string}::${string}`;
export type MoveOptionType = MoveType | null | undefined;
/**
* String representation of a on-chain Move struct type.
Expand Down Expand Up @@ -866,7 +866,7 @@ export type LedgerInfo = {
*/
export type Block = {
block_height: string;
block_hash: `0x${string}`;
block_hash: string;
block_timestamp: string;
first_version: string;
last_version: string;
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/transaction/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export async function rawTransactionHelper(
const rawTransaction = await aptos.generateTransaction({
sender: senderAccount.accountAddress.toString(),
data: {
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::tx_args_module::${functionName}`,
function: `${senderAccount.accountAddress.toString()}::tx_args_module::${functionName}`,
typeArguments: typeArgs,
functionArguments: args,
},
Expand Down
8 changes: 4 additions & 4 deletions tests/e2e/transaction/signTransaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ describe("sign transaction", () => {
const rawTxn = await aptos.generateTransaction({
sender: senderAccount.accountAddress.toString(),
data: {
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::transfer`,
function: `${senderAccount.accountAddress.toString()}::transfer::transfer`,
functionArguments: [new U64(1), recieverAccounts[0].accountAddress],
},
});
Expand All @@ -67,7 +67,7 @@ describe("sign transaction", () => {
sender: senderAccount.accountAddress.toString(),
data: {
multisigAddress: secondarySignerAccount.accountAddress,
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::transfer`,
function: `${senderAccount.accountAddress.toString()}::transfer::transfer`,
functionArguments: [new U64(1), recieverAccounts[0].accountAddress],
},
});
Expand Down Expand Up @@ -104,7 +104,7 @@ describe("sign transaction", () => {
const rawTxn = await aptos.generateTransaction({
sender: senderSecp256k1Account.accountAddress.toString(),
data: {
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::transfer`,
function: `${senderAccount.accountAddress.toString()}::transfer::transfer`,
functionArguments: [new U64(1), recieverAccounts[0].accountAddress],
},
});
Expand All @@ -122,7 +122,7 @@ describe("sign transaction", () => {
sender: senderSecp256k1Account.accountAddress.toString(),
data: {
multisigAddress: secondarySignerAccount.accountAddress,
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::transfer`,
function: `${senderAccount.accountAddress.toString()}::transfer::transfer`,
functionArguments: [new U64(1), recieverAccounts[0].accountAddress],
},
});
Expand Down
24 changes: 12 additions & 12 deletions tests/e2e/transaction/transactionSimulation.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ describe("transaction simulation", () => {
const rawTxn = await aptos.generateTransaction({
sender: senderAccount.accountAddress.toString(),
data: {
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::transfer`,
function: `${senderAccount.accountAddress.toString()}::transfer::transfer`,
functionArguments: [new U64(1), recieverAccounts[0].accountAddress],
},
});
Expand All @@ -55,7 +55,7 @@ describe("transaction simulation", () => {
sender: senderAccount.accountAddress.toString(),
data: {
multisigAddress: secondarySignerAccount.accountAddress,
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::transfer`,
function: `${senderAccount.accountAddress.toString()}::transfer::transfer`,
functionArguments: [new U64(1), recieverAccounts[0].accountAddress],
},
});
Expand Down Expand Up @@ -98,7 +98,7 @@ describe("transaction simulation", () => {
sender: senderAccount.accountAddress.toString(),
secondarySignerAddresses: [secondarySignerAccount.accountAddress.toString()],
data: {
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::two_by_two`,
function: `${senderAccount.accountAddress.toString()}::transfer::two_by_two`,
functionArguments: [
new U64(100),
new U64(200),
Expand Down Expand Up @@ -142,7 +142,7 @@ describe("transaction simulation", () => {
sender: senderAccount.accountAddress.toString(),
feePayerAddress: feePayerAccount.accountAddress.toString(),
data: {
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::transfer`,
function: `${senderAccount.accountAddress.toString()}::transfer::transfer`,
functionArguments: [new U64(1), recieverAccounts[0].accountAddress],
},
});
Expand All @@ -159,7 +159,7 @@ describe("transaction simulation", () => {
feePayerAddress: feePayerAccount.accountAddress.toString(),
data: {
multisigAddress: secondarySignerAccount.accountAddress,
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::transfer`,
function: `${senderAccount.accountAddress.toString()}::transfer::transfer`,
functionArguments: [new U64(1), recieverAccounts[0].accountAddress],
},
});
Expand All @@ -177,7 +177,7 @@ describe("transaction simulation", () => {
secondarySignerAddresses: [secondarySignerAccount.accountAddress.toString()],
feePayerAddress: feePayerAccount.accountAddress.toString(),
data: {
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::two_by_two`,
function: `${senderAccount.accountAddress.toString()}::transfer::two_by_two`,
functionArguments: [
new U64(100),
new U64(200),
Expand Down Expand Up @@ -219,7 +219,7 @@ describe("transaction simulation", () => {
const rawTxn = await aptos.generateTransaction({
sender: senderSecp256k1Account.accountAddress.toString(),
data: {
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::transfer`,
function: `${senderAccount.accountAddress.toString()}::transfer::transfer`,
functionArguments: [new U64(1), recieverAccounts[0].accountAddress],
},
});
Expand All @@ -234,7 +234,7 @@ describe("transaction simulation", () => {
sender: senderSecp256k1Account.accountAddress.toString(),
data: {
multisigAddress: secondarySignerAccount.accountAddress,
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::transfer`,
function: `${senderAccount.accountAddress.toString()}::transfer::transfer`,
functionArguments: [new U64(1), recieverAccounts[0].accountAddress],
},
});
Expand Down Expand Up @@ -277,7 +277,7 @@ describe("transaction simulation", () => {
sender: senderSecp256k1Account.accountAddress.toString(),
secondarySignerAddresses: [secondarySignerAccount.accountAddress.toString()],
data: {
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::two_by_two`,
function: `${senderAccount.accountAddress.toString()}::transfer::two_by_two`,
functionArguments: [
new U64(100),
new U64(200),
Expand Down Expand Up @@ -321,7 +321,7 @@ describe("transaction simulation", () => {
sender: senderSecp256k1Account.accountAddress.toString(),
feePayerAddress: feePayerAccount.accountAddress.toString(),
data: {
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::transfer`,
function: `${senderAccount.accountAddress.toString()}::transfer::transfer`,
functionArguments: [new U64(1), recieverAccounts[0].accountAddress],
},
});
Expand All @@ -338,7 +338,7 @@ describe("transaction simulation", () => {
feePayerAddress: feePayerAccount.accountAddress.toString(),
data: {
multisigAddress: secondarySignerAccount.accountAddress,
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::transfer`,
function: `${senderAccount.accountAddress.toString()}::transfer::transfer`,
functionArguments: [new U64(1), recieverAccounts[0].accountAddress],
},
});
Expand All @@ -356,7 +356,7 @@ describe("transaction simulation", () => {
secondarySignerAddresses: [secondarySignerAccount.accountAddress.toString()],
feePayerAddress: feePayerAccount.accountAddress.toString(),
data: {
function: `0x${senderAccount.accountAddress.toStringWithoutPrefix()}::transfer::two_by_two`,
function: `${senderAccount.accountAddress.toString()}::transfer::two_by_two`,
functionArguments: [
new U64(100),
new U64(200),
Expand Down

0 comments on commit c903b3f

Please sign in to comment.