fix: get chainId param from web3
MODIFY
src/common/Utils.ts
src/common/Utils.ts
@@ -10,8 +10,7 @@ export class Utils {
])
return EthUtil.keccak256(orderData)
}
- // @todo take chain id as a param
- getTypedData({ token, spender, tokenIdOrAmount, data, expiration }) {
+ getTypedData({ token, spender, tokenIdOrAmount, data, expiration, chainId }) {
return {
types: {
EIP712Domain: [
@@ -30,7 +29,7 @@ export class Utils {
domain: {
name: 'Matic Network',
version: '1',
- chainId: 15001,
+ chainId: chainId,
contract: token,
},
primaryType: 'TokenTransferOrder',

MODIFY
src/index.ts
src/index.ts
@@ -168,7 +168,7 @@ export default class Matic extends ContractsBase {
return this.depositManager.approveERC20(token, amount, options)
}
- getTransferSignature(sellOrder: order, buyOrder: order, options: SendOptions) {
+ async getTransferSignature(sellOrder: order, buyOrder: order, options: SendOptions) {
if (!sellOrder.orderId || !sellOrder.spender) {
throw new Error('orderId or spender missing from sell order')
}
@@ -183,12 +183,14 @@ export default class Matic extends ContractsBase {
expiration: sellOrder.expiry,
}
const orderHash = this.utils.getOrderHash(orderObj)
+ let chainId = await this.web3Client.web3.eth.net.getId()
const dataToSign = {
token: sellOrder.token,
tokenIdOrAmount: sellOrder.amount,
spender: sellOrder.spender,
data: orderHash,
expiration: sellOrder.expiry,
+ chainId: chainId,
}
const typedData = this.utils.getTypedData(dataToSign)
const wallet = this.web3Client.getWallet()

fix: get chainId param from web3