Skip to content

Commit

Permalink
Merge pull request #747 from polywrap/eth-plugin-chainid-type
Browse files Browse the repository at this point in the history
change chainId from Int/UInt to BigInt type Ethereum plugin
  • Loading branch information
dOrgJelli authored Mar 22, 2022
2 parents 0e808c1 + 1e63b6b commit 77430d3
Show file tree
Hide file tree
Showing 9 changed files with 91 additions and 93 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ type Ethereum_TxRequest @imported(
gasPrice: BigInt
data: String
value: BigInt
chainId: UInt32
chainId: BigInt
type: UInt32
}

Expand Down Expand Up @@ -343,7 +343,7 @@ type Ethereum_Network @imported(
nativeType: "Network"
) {
name: String!
chainId: Int!
chainId: BigInt!
ensAddress: String
}

Expand All @@ -360,7 +360,7 @@ type Ethereum_TxResponse @imported(
gasPrice: BigInt
data: String!
value: BigInt!
chainId: UInt32!
chainId: BigInt!
blockNumber: BigInt
blockHash: String
timestamp: UInt32
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/__tests__/plugin/expected-types/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ type Ethereum_TxRequest @imported(
gasPrice: BigInt
data: String
value: BigInt
chainId: UInt32
chainId: BigInt
type: UInt32
}
Expand Down Expand Up @@ -343,7 +343,7 @@ type Ethereum_Network @imported(
nativeType: "Network"
) {
name: String!
chainId: Int!
chainId: BigInt!
ensAddress: String
}
Expand All @@ -360,7 +360,7 @@ type Ethereum_TxResponse @imported(
gasPrice: BigInt
data: String!
value: BigInt!
chainId: UInt32!
chainId: BigInt!
blockNumber: BigInt
blockHash: String
timestamp: UInt32
Expand Down
6 changes: 3 additions & 3 deletions packages/cli/src/__tests__/plugin/expected-types/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ export interface Ethereum_TxRequest {
gasPrice?: BigInt | null;
data?: String | null;
value?: BigInt | null;
chainId?: UInt32 | null;
chainId?: BigInt | null;
type?: UInt32 | null;
}

Expand Down Expand Up @@ -104,7 +104,7 @@ export interface Ethereum_EventNotification {
/* URI: "ens/ethereum.web3api.eth" */
export interface Ethereum_Network {
name: String;
chainId: Int;
chainId: BigInt;
ensAddress?: String | null;
}

Expand All @@ -118,7 +118,7 @@ export interface Ethereum_TxResponse {
gasPrice?: BigInt | null;
data: String;
value: BigInt;
chainId: UInt32;
chainId: BigInt;
blockNumber?: BigInt | null;
blockHash?: String | null;
timestamp?: UInt32 | null;
Expand Down
14 changes: 7 additions & 7 deletions packages/cli/src/__tests__/project/sample.ts
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,7 @@ type Ethereum_TxRequest @imported(
gasPrice: BigInt
data: String
value: BigInt
chainId: UInt32
chainId: BigInt
type: UInt32
}
Expand Down Expand Up @@ -265,7 +265,7 @@ type Ethereum_Network @imported(
nativeType: "Network"
) {
name: String!
chainId: Int!
chainId: BigInt!
ensAddress: String
}
Expand Down Expand Up @@ -424,7 +424,7 @@ type Ethereum_TxResponse @imported(
gasPrice: BigInt
data: String!
value: BigInt!
chainId: UInt32!
chainId: BigInt!
blockNumber: BigInt
blockHash: String
timestamp: UInt32
Expand Down Expand Up @@ -498,7 +498,7 @@ type Ethereum_TxRequest @imported(
gasPrice: BigInt
data: String
value: BigInt
chainId: UInt32
chainId: BigInt
type: UInt32
}
Expand Down Expand Up @@ -792,7 +792,7 @@ type Ethereum_TxRequest @imported(
gasPrice: BigInt
data: String
value: BigInt
chainId: UInt32
chainId: BigInt
type: UInt32
}
Expand Down Expand Up @@ -852,7 +852,7 @@ type Ethereum_Network @imported(
nativeType: "Network"
) {
name: String!
chainId: Int!
chainId: BigInt!
ensAddress: String
}
Expand All @@ -869,7 +869,7 @@ type Ethereum_TxResponse @imported(
gasPrice: BigInt
data: String!
value: BigInt!
chainId: UInt32!
chainId: BigInt!
blockNumber: BigInt
blockHash: String
timestamp: UInt32
Expand Down
6 changes: 3 additions & 3 deletions packages/js/plugins/ethereum/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ type TxResponse {
gasPrice: BigInt
data: String!
value: BigInt!
chainId: UInt32!
chainId: BigInt!
blockNumber: BigInt
blockHash: String
timestamp: UInt32
Expand All @@ -48,7 +48,7 @@ type TxRequest {
gasPrice: BigInt
data: String
value: BigInt
chainId: UInt32
chainId: BigInt
type: UInt32
}

Expand Down Expand Up @@ -93,7 +93,7 @@ type Connection {

type Network {
name: String!
chainId: Int!
chainId: BigInt!
ensAddress: String
}

Expand Down
4 changes: 2 additions & 2 deletions packages/js/plugins/ethereum/src/__tests__/e2e.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ describe("Ethereum Plugin", () => {

expect(mainnetNetwork.data).toBeTruthy();
expect(mainnetNetwork.errors).toBeFalsy();
expect(mainnetNetwork.data?.getNetwork.chainId).toBe(1);
expect(mainnetNetwork.data?.getNetwork.chainId).toBe("1");
expect(mainnetNetwork.data?.getNetwork.name).toBe("homestead");
expect(mainnetNetwork.data?.getNetwork.ensAddress).toBe("0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e");

Expand All @@ -646,7 +646,7 @@ describe("Ethereum Plugin", () => {

expect(polygonNetwork.data).toBeTruthy();
expect(polygonNetwork.errors).toBeFalsy();
expect(polygonNetwork.data?.getNetwork.chainId).toBe(137);
expect(polygonNetwork.data?.getNetwork.chainId).toBe("137");
expect(polygonNetwork.data?.getNetwork.name).toBe("matic");
expect(polygonNetwork.data?.getNetwork.ensAddress).toBeFalsy();
});
Expand Down
2 changes: 1 addition & 1 deletion packages/js/plugins/ethereum/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ export class EthereumPlugin extends Plugin {
const network = await provider.getNetwork();
return {
name: network.name,
chainId: network.chainId,
chainId: network.chainId.toString(),
ensAddress: network.ensAddress,
};
}
Expand Down
6 changes: 3 additions & 3 deletions packages/js/plugins/ethereum/src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ export const toTxResponse = (
gasPrice: response.gasPrice?.toString(),
data: response.data,
value: response.value.toString(),
chainId: response.chainId,
chainId: response.chainId.toString(),
blockNumber: response.blockNumber?.toString(),
blockHash: response.blockHash,
timestamp: response.timestamp,
Expand All @@ -80,7 +80,7 @@ export const toTxRequest = (
gasPrice: request.gasPrice?.toString(),
data: request.data?.toString(),
value: request.value?.toString(),
chainId: request.chainId,
chainId: request.chainId?.toString(),
type: request.type,
});

Expand All @@ -98,7 +98,7 @@ export const fromTxRequest = (
: undefined,
data: request.data || undefined,
value: request.value ? ethers.BigNumber.from(request.value) : undefined,
chainId: request.chainId || undefined,
chainId: request.chainId ? Number.parseInt(request.chainId) : undefined,
type: request.type || undefined,
});

Expand Down
Loading

0 comments on commit 77430d3

Please sign in to comment.