Skip to content

Commit

Permalink
format + remove snamel in V0 ts
Browse files Browse the repository at this point in the history
  • Loading branch information
gaetbout committed Nov 7, 2024
1 parent 01deebe commit de15dd1
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 21 deletions.
10 changes: 5 additions & 5 deletions scripts/v0/SimpleStruct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const types = {
};

interface SimpleStruct {
some_felt252: string;
some_u128: string;
someFelt252: string;
someU128: string;
}

function getDomain(chainId: string): StarknetDomain {
Expand All @@ -36,13 +36,13 @@ function getTypedData(myStruct: SimpleStruct, chainId: string): TypedData {
types,
primaryType: "SimpleStruct",
domain: getDomain(chainId),
message: { ...myStruct },
message: { som_felt252: myStruct.someFelt252, some_u128: myStruct.someU128 },
};
}

const simpleStruct: SimpleStruct = {
some_felt252: "712",
some_u128: "42",
someFelt252: "712",
someU128: "42",
};

console.log(`test test_valid_hash ${getTypedDataHash(simpleStruct, "0", 420n)};`);
10 changes: 5 additions & 5 deletions scripts/v0/StructWithArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@ const types = {
};

interface StructWithArray {
some_felt252: string;
some_array: string[];
someFelt252: string;
someArray: string[];
}

function getDomain(chainId: string): StarknetDomain {
Expand All @@ -36,13 +36,13 @@ function getTypedData(myStruct: StructWithArray, chainId: string): TypedData {
types,
primaryType: "StructWithArray",
domain: getDomain(chainId),
message: { ...myStruct },
message: { some_felt252: myStruct.someFelt252, some_array: myStruct.someArray },
};
}

const structWithArray: StructWithArray = {
some_felt252: "712",
some_array: ["4", "2"],
someFelt252: "712",
someArray: ["4", "2"],
};

console.log(`test test_valid_hash ${getTypedDataHash(structWithArray, "0", 420n)};`);
10 changes: 5 additions & 5 deletions scripts/v0/StructWithMerkletree.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ const types = {
};

interface StructWithMerkletree {
some_felt252: string;
some_merkletree_root: SomeLeaf[];
someFelt252: string;
someMerkletreeRoot: SomeLeaf[];
}

export interface SomeLeaf {
Expand All @@ -41,13 +41,13 @@ function getTypedData(myStruct: StructWithMerkletree, chainId: string): TypedDat
types,
primaryType: "StructWithMerkletree",
domain: getDomain(chainId),
message: { ...myStruct },
message: { some_felt252: myStruct.someFelt252, some_merkletree_root: myStruct.someMerkletreeRoot },
};
}

const structWithMerkletree: StructWithMerkletree = {
some_felt252: "712",
some_merkletree_root: [{ contract_address: "0x1" }, { contract_address: "0x2" }],
someFelt252: "712",
someMerkletreeRoot: [{ contract_address: "0x1" }, { contract_address: "0x2" }],
};

console.log(`test test_valid_hash ${getTypedDataHash(structWithMerkletree, "0", 420n)};`);
10 changes: 5 additions & 5 deletions scripts/v0/StructWithU256.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ const types = {
};

interface StructWithU256 {
some_felt252: string;
some_u256: Uint256;
someFelt252: string;
someU256: Uint256;
}

function getDomain(chainId: string): StarknetDomain {
Expand All @@ -40,13 +40,13 @@ function getTypedData(myStruct: StructWithU256, chainId: string): TypedData {
types,
primaryType: "StructWithU256",
domain: getDomain(chainId),
message: { ...myStruct },
message: { some_felt252: myStruct.someFelt252, some_u256: myStruct.someU256 },
};
}

const structWithU256: StructWithU256 = {
some_felt252: "712",
some_u256: uint256.bnToUint256(42),
someFelt252: "712",
someU256: uint256.bnToUint256(42),
};

console.log(`test test_valid_hash ${getTypedDataHash(structWithU256, "0", 420n)};`);
2 changes: 1 addition & 1 deletion scripts/v1/StructWithArray.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ function getTypedData(myStruct: StructWithArray, chainId: string): TypedData {
types,
primaryType: "StructWithArray",
domain: getDomain(chainId),
message: { "Some felt252": myStruct.someFelt252, "Some array": myStruct.someArray},
message: { "Some felt252": myStruct.someFelt252, "Some array": myStruct.someArray },
};
}

Expand Down

0 comments on commit de15dd1

Please sign in to comment.