Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
Electr1Xx committed Nov 13, 2023
1 parent 18a011b commit 2c37361
Show file tree
Hide file tree
Showing 16 changed files with 1,321 additions and 238 deletions.
2 changes: 1 addition & 1 deletion packages/connector/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export { MetamaskSnap } from './snap';
export * from './types';
export { isMetamaskInstalled, isSnapInstalled } from './utils';

export const defaultSnapOrigin = 'npm:@rarimo/rarime';
export const defaultSnapOrigin = 'local:http://localhost:8081';

export const enableSnap = async (
snapOrigin?: string,
Expand Down
Binary file added packages/snap/files/circuits/authV2/circuit.wasm
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
8 changes: 5 additions & 3 deletions packages/snap/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
"license": "(MIT-0 OR Apache-2.0)",
"files": [
"dist/",
"files/",
"images/",
"snap.manifest.json",
"README.md"
Expand Down Expand Up @@ -43,8 +44,8 @@
"@iden3/js-jwz": "1.0.0-beta.2",
"@iden3/js-merkletree": "1.0.0-beta.1",
"@metamask/snaps-jest": "0.35.2-flask.1",
"@metamask/snaps-types": "0.32.2",
"@metamask/snaps-ui": "0.32.2",
"@metamask/snaps-types": "3.1.0",
"@metamask/snaps-ui": "3.1.0",
"@rarimo/rarime-connector": "0.8.0",
"buffer": "6.0.3",
"ethers": "5.7.2",
Expand All @@ -60,7 +61,8 @@
"@metamask/eslint-config-jest": "10.0.0",
"@metamask/eslint-config-nodejs": "10.0.0",
"@metamask/eslint-config-typescript": "10.0.0",
"@metamask/snaps-cli": "0.32.2",
"@metamask/snaps-cli": "3.0.1",
"@metamask/utils": "8.2.1",
"@typechain/ethers-v5": "11.1.1",
"@types/intl": "1.2.0",
"@types/uuid": "9.0.2",
Expand Down
11 changes: 11 additions & 0 deletions packages/snap/post-process.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
const fs = require('fs');
const pathUtils = require('path');
const { postProcessBundle } = require('@metamask/snaps-utils');

const bundlePath = pathUtils.join('dist', 'bundle.js');
console.log('Bundle replace code to SES', bundlePath);

// eslint-disable-next-line node/no-sync
let bundleString = fs.readFileSync(bundlePath, 'utf8');
console.log('[Start]: MetaMask Snaps transform');

bundleString = postProcessBundle(bundleString, {
stripComments: true,
}).code;

console.log('[End]: MetaMask Snaps transform');

console.log('[Start]: Custom transform');

bundleString = 'var Worker = {};\n'.concat(bundleString);

Expand Down Expand Up @@ -80,6 +90,7 @@ bundleString = bundleString.replaceAll(

// Fix TextEncoder and TextDecoder
bundleString = bundleString.replace('var empty2 = null;', 'var empty2 = {};');
console.log('[End]: Custom transform');

// eslint-disable-next-line node/no-sync
fs.writeFileSync(bundlePath, bundleString);
Expand Down
16 changes: 14 additions & 2 deletions packages/snap/snap.manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,27 @@
"url": "https://github.com/rarimo/rarime.git"
},
"source": {
"shasum": "y+9O7z7mlNe85T/RCp32jySBwGoJ9tf0NrKlLrpgNdw=",
"shasum": "NV5BEUftiZGscEKmFh0Su7LVz8EJY+jSl+251EXg8lM=",
"location": {
"npm": {
"filePath": "dist/bundle.js",
"iconPath": "images/icon.svg",
"packageName": "@rarimo/rarime",
"registry": "https://registry.npmjs.org/"
}
}
},
"files": [
"./files/circuits/authV2/circuit.wasm",
"./files/circuits/authV2/circuit_final.zkey",
"./files/circuits/credentialAtomicQueryMTPV2/circuit.wasm",
"./files/circuits/credentialAtomicQueryMTPV2/circuit_final.zkey",
"./files/circuits/credentialAtomicQueryMTPV2OnChain/circuit.wasm",
"./files/circuits/credentialAtomicQueryMTPV2OnChain/circuit_final.zkey",
"./files/circuits/credentialAtomicQuerySigV2/circuit.wasm",
"./files/circuits/credentialAtomicQuerySigV2/circuit_final.zkey",
"./files/circuits/credentialAtomicQuerySigV2OnChain/circuit.wasm",
"./files/circuits/credentialAtomicQuerySigV2OnChain/circuit_final.zkey"
]
},
"initialPermissions": {
"snap_dialog": {},
Expand Down
10 changes: 8 additions & 2 deletions packages/snap/src/helpers/file-helpers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
export const readBytesFile = async (path: string) => {
const response = await fetch(path);
return new Uint8Array(await response?.arrayBuffer?.());
const response = await snap.request({
method: 'snap_getFile',
params: {
path,
},
});
console.log(response);
return response;
};
Loading

0 comments on commit 2c37361

Please sign in to comment.