-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
implement the propose new masternode part
- Loading branch information
Showing
3 changed files
with
164 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import Web3 from 'web3'; | ||
|
||
export interface Web3WithExtension extends Web3 { | ||
xdcSubnet: { | ||
getCandidates: (epochNum: "latest") => Promise<{ | ||
candidates: { | ||
[key: string]: { | ||
capacity: number; | ||
status: 'MASTERNODE' | 'PROPOSED' | 'SLASHED' | ||
} | ||
}; | ||
epoch: number; | ||
success: boolean; | ||
}> | ||
}; | ||
} | ||
|
||
export const networkExtensions = (extensionName = 'xdcSubnet') => { | ||
return { | ||
property: extensionName, | ||
methods: [ | ||
{ | ||
name: 'getCandidates', | ||
params: 1, | ||
call: 'eth_getCandidates', | ||
} | ||
], | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
export const getSigningMsg = (name: string, chainId: number, nonce: number, encodedData: string, value: string) => { | ||
return JSON.stringify({ | ||
domain: { | ||
chainId: chainId.toString(), | ||
name, | ||
// verifyingContract: "0x0000000000000000000000000000000000000088", // To be replaced by the actual sm address | ||
version: "1" | ||
}, | ||
message: { | ||
nonce: Number(nonce), | ||
gasPrice: 250000000, | ||
gasLimit: 220000, | ||
to: '0x0000000000000000000000000000000000000088', | ||
value, | ||
data: encodedData, | ||
}, | ||
primaryType: 'Grandmaster', | ||
types: { | ||
// This refers to the domain the contract is hosted on. | ||
EIP712Domain: [ | ||
{ name: 'name', type: 'string' }, | ||
{ name: 'version', type: 'string' }, | ||
{ name: 'chainId', type: 'uint256' }, | ||
// { name: 'verifyingContract', type: 'address' }, | ||
], | ||
Grandmaster: [ | ||
{ name: 'nonce', type: 'uint256' }, | ||
{ name: 'gasPrice', type: 'uint256' }, | ||
{ name: 'gasLimit', type: 'uint256' }, | ||
{ name: 'to', type: 'string' }, | ||
{ name: 'value', type: 'string' }, | ||
{ name: 'data', type: 'string' }, | ||
], | ||
}, | ||
}); | ||
} |