Skip to content

Commit

Permalink
fix: update to iso-filecoin 5.x
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomrdias committed Dec 30, 2024
1 parent abf7d5a commit ff08149
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 13 deletions.
13 changes: 7 additions & 6 deletions packages/snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"files": [
"src/**/*.ts",
"src/**/*.tsx",
"src/**/*.svg",
"tsconfig.json",
"snap.config.ts"
],
Expand Down Expand Up @@ -85,15 +86,15 @@
}
},
"dependencies": {
"@metamask/key-tree": "^9.1.2",
"@metamask/key-tree": "^10.0.2",
"@metamask/snaps-sdk": "^6.6.0",
"@paulmillr/qr": "^0.2.0",
"@paulmillr/qr": "^0.3.0",
"dequal": "^2.0.3",
"iso-base": "^4.0.0",
"iso-filecoin": "^4.1.0",
"iso-filecoin": "^5.1.1",
"merge-options": "^3.0.4",
"viem": "^2.21.36",
"zod": "^3.22.4"
"viem": "^2.21.59",
"zod": "^3.24.1"
},
"devDependencies": {
"@metamask/snaps-cli": "6.5.1",
Expand All @@ -104,7 +105,7 @@
"onchange": "^7.1.0",
"playwright-test": "^14.1.6",
"type-fest": "^4.26.1",
"typescript": "5.6.3"
"typescript": "5.7.2"
},
"publishConfig": {
"provenance": true
Expand Down
6 changes: 3 additions & 3 deletions packages/snap/src/filforwarder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,14 +76,14 @@ const abi = [
stateMutability: 'payable',
type: 'function',
},
]
] as const

const contractAddress: `0x${string}` =
'0x2B3ef6906429b580b7b2080de5CA893BC282c225'

const chainIds = {
filecoinMainnet: 'eip155:13a',
filecoinCalibrationTestnet: 'eip155:4cb2f',
filecoinMainnet: 'eip155:314',
filecoinCalibrationTestnet: 'eip155:314159',
}

// FEVM FilForwarder contract metadata
Expand Down
7 changes: 4 additions & 3 deletions packages/snap/src/rpc/sign-message.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { base64pad } from 'iso-base/rfc4648'
import { utf8 } from 'iso-base/utf8'
import * as Address from 'iso-filecoin/address'
import { Message, Schemas } from 'iso-filecoin/message'
import { RPC } from 'iso-filecoin/rpc'
Expand Down Expand Up @@ -99,7 +100,7 @@ export async function signMessage(
result: {
message,
signature: {
data: base64pad.encode(sig),
data: base64pad.encode(sig.data),
type: 'SECP256K1',
},
},
Expand Down Expand Up @@ -153,10 +154,10 @@ export async function signMessageRaw(
})

if (conf) {
const sig = sign(account.privateKey, 'SECP256K1', message)
const sig = sign(account.privateKey, 'SECP256K1', utf8.decode(message))
return {
error: null,
result: base64pad.encode(sig),
result: base64pad.encode(sig.data),
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/snap/test/methods.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ test.describe('filsnap testnet', () => {
const { result } = await signRaw

expect(result).toStrictEqual(
'BjNeqpqxb9CdnxVbE3J8YGHMg9kZjAz95mnnlASUSGgluIhTvaNRB5/Qx5/dKXqzBvpSclOXQfkeeRvqvo3jqAA='
'WNtAyos6hGibMdT1XXIJTLLTXYg1nWrtKL7fcL/8jMQDSf72NYlbfxZojWPNJVbbrDCeZVXLygtgZt+ttPVv7AE='
)
})

Expand Down

0 comments on commit ff08149

Please sign in to comment.