diff --git a/.github/workflows/build.yaml b/.github/workflows/build.yaml index 94b6401..e53506b 100644 --- a/.github/workflows/build.yaml +++ b/.github/workflows/build.yaml @@ -2,14 +2,15 @@ name: Build and Publish NPM Package on: push: - branches: - - main - # Publish semver tags as releases. + branches: [main] tags: ["v*.*.*"] jobs: build: runs-on: ubuntu-latest + permissions: + contents: read + packages: write steps: - name: Checkout code @@ -26,10 +27,14 @@ jobs: - name: Add @sepior/tsmsdkv2 Typescript Definitions run: cp ./types/* ./node_modules/@sepior/tsmsdkv2/ + - name: Run Tests + run: npm test + continue-on-error: true # ToDo: remove once integration with hosted BV sandbox is in place. + - name: Build TypeScript application run: npm run build - name: Publish to GitHub npm package registry env: NODE_AUTH_TOKEN: ${{secrets.GITHUB_TOKEN}} - run: npm publish --registry=https://npm.pkg.github.com/OWNER \ No newline at end of file + run: npm publish \ No newline at end of file diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index fde7bf3..ca6e3ab 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -4,6 +4,9 @@ on: push: branches: - main + pull_request: + branches: + - main jobs: test: diff --git a/.gitignore b/.gitignore index e9a0d59..de1e5ea 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ init **/key.txt **/.env -**/node_modules \ No newline at end of file +**/node_modules +/dist/ \ No newline at end of file diff --git a/README.md b/README.md index 45e8dd3..9ef3b9f 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,9 @@ Blockdaemon BuilderVault [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193) Com ## Installation ```bash -npm config set @sepior:registry=https://gitlab.com/api/v4/projects/56306653/packages/npm/ # Builder Vault nodejsSDK repository +npm config set @sepior:registry=https://gitlab.com/api/v4/projects/56306653/packages/npm/ # Builder Vault nodejsSDK public repository +npm config set @blockdaemon:registry=https://npm.pkg.github.com/ # Builder Vault Web3 provider nodejsSDK private repository +npm config set //npm.pkg.github.com/:_authToken=YOUR_GITHUB_PAT npm install @blockdaemon/buildervault-web3-provider ``` diff --git a/dist/package.json b/dist/package.json deleted file mode 100644 index bbe50f6..0000000 --- a/dist/package.json +++ /dev/null @@ -1,41 +0,0 @@ -{ - "name": "@blockdaemon/buildervault-web3-provider", - "version": "0.0.1", - "description": "EIP-1193 Compatible Ethereum provider for BuilderVault", - "repository": "github:blockdaemon/buildervault-web3-provider", - "author": "BuilderVault", - "license": "MIT", - "main": "dist/src/index.js", - "types": "dist/src/index.d.ts", - "scripts": { - "build": "tsc", - "watch": "tsc -w", - "test": "vitest" - }, - "files": [ - "dist/", - "README.md" - ], - "devDependencies": { - "@typechain/ethers-v5": "^10.2.0", - "@types/debug": "^4.1.12", - "@types/node-fetch": "^2.6.2", - "dotenv": "^16.0.3", - "ts-node": "10.8.1", - "typechain": "^8.1.1", - "typescript": "4.7.4", - "vitest": "^2.1.4", - "web3": "^4.1.2" - }, - "dependencies": { - "@sepior/tsmsdkv2": "^65.0.0", - "asn1.js": "^5.4.1", - "crypto": "^1.0.1", - "debug": "^4.3.7", - "https-proxy-agent": "^7.0.2", - "web3-eth-abi": "^4.3.0", - "web3-eth-accounts": "^4.2.1", - "web3-providers-http": "1.8.0", - "web3-utils": "^4.3.1" - } -} diff --git a/dist/src/constants.d.ts b/dist/src/constants.d.ts deleted file mode 100644 index 8e8dab8..0000000 --- a/dist/src/constants.d.ts +++ /dev/null @@ -1,3 +0,0 @@ -export declare const DEBUG_NAMESPACE = "buildervault-web3-provider"; -export declare const DEBUG_NAMESPACE_REQUESTS_AND_RESPONSES: string; -//# sourceMappingURL=constants.d.ts.map \ No newline at end of file diff --git a/dist/src/constants.d.ts.map b/dist/src/constants.d.ts.map deleted file mode 100644 index ea9ec4a..0000000 --- a/dist/src/constants.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,eAAe,+BAA+B,CAAA;AAC3D,eAAO,MAAM,sCAAsC,QAA+B,CAAA"} \ No newline at end of file diff --git a/dist/src/constants.js b/dist/src/constants.js deleted file mode 100644 index c89eb5c..0000000 --- a/dist/src/constants.js +++ /dev/null @@ -1,6 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.DEBUG_NAMESPACE_REQUESTS_AND_RESPONSES = exports.DEBUG_NAMESPACE = void 0; -exports.DEBUG_NAMESPACE = 'buildervault-web3-provider'; -exports.DEBUG_NAMESPACE_REQUESTS_AND_RESPONSES = `${exports.DEBUG_NAMESPACE}:req_res`; -//# sourceMappingURL=constants.js.map \ No newline at end of file diff --git a/dist/src/constants.js.map b/dist/src/constants.js.map deleted file mode 100644 index 242a104..0000000 --- a/dist/src/constants.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,eAAe,GAAG,4BAA4B,CAAA;AAC9C,QAAA,sCAAsC,GAAG,GAAG,uBAAe,UAAU,CAAA"} \ No newline at end of file diff --git a/dist/src/index.d.ts b/dist/src/index.d.ts deleted file mode 100644 index 977348e..0000000 --- a/dist/src/index.d.ts +++ /dev/null @@ -1,6 +0,0 @@ -export { version } from "../package.json"; -export * from "./provider"; -export * from "./types"; -export * from "./constants"; -export * from "./utils"; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/dist/src/index.d.ts.map b/dist/src/index.d.ts.map deleted file mode 100644 index 276c9cc..0000000 --- a/dist/src/index.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAA;AACzC,cAAc,YAAY,CAAC;AAC3B,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC"} \ No newline at end of file diff --git a/dist/src/index.js b/dist/src/index.js deleted file mode 100644 index ae3ef33..0000000 --- a/dist/src/index.js +++ /dev/null @@ -1,24 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.version = void 0; -var package_json_1 = require("../package.json"); -Object.defineProperty(exports, "version", { enumerable: true, get: function () { return package_json_1.version; } }); -__exportStar(require("./provider"), exports); -__exportStar(require("./types"), exports); -__exportStar(require("./constants"), exports); -__exportStar(require("./utils"), exports); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/dist/src/index.js.map b/dist/src/index.js.map deleted file mode 100644 index 16beaa3..0000000 --- a/dist/src/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,gDAAyC;AAAhC,uGAAA,OAAO,OAAA;AAChB,6CAA2B;AAC3B,0CAAwB;AACxB,8CAA4B;AAC5B,0CAAwB"} \ No newline at end of file diff --git a/dist/src/jsonRpcUtils.d.ts b/dist/src/jsonRpcUtils.d.ts deleted file mode 100644 index d64c4c4..0000000 --- a/dist/src/jsonRpcUtils.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export declare function payloadId(): number; -export declare function formatJsonRpcRequest(method: string, params: any[], id?: number): any; -export declare function formatJsonRpcResult(id: number, result: any): any; -//# sourceMappingURL=jsonRpcUtils.d.ts.map \ No newline at end of file diff --git a/dist/src/jsonRpcUtils.d.ts.map b/dist/src/jsonRpcUtils.d.ts.map deleted file mode 100644 index 82e467e..0000000 --- a/dist/src/jsonRpcUtils.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"jsonRpcUtils.d.ts","sourceRoot":"","sources":["../../src/jsonRpcUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,IAAI,MAAM,CAIlC;AAED,wBAAgB,oBAAoB,CAClC,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,GAAG,EAAE,EACb,EAAE,CAAC,EAAE,MAAM,GACV,GAAG,CAOL;AAED,wBAAgB,mBAAmB,CACjC,EAAE,EAAE,MAAM,EACV,MAAM,EAAE,GAAG,GACV,GAAG,CAML"} \ No newline at end of file diff --git a/dist/src/jsonRpcUtils.js b/dist/src/jsonRpcUtils.js deleted file mode 100644 index c7fd484..0000000 --- a/dist/src/jsonRpcUtils.js +++ /dev/null @@ -1,27 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.formatJsonRpcResult = exports.formatJsonRpcRequest = exports.payloadId = void 0; -function payloadId() { - const date = Date.now() * Math.pow(10, 3); - const extra = Math.floor(Math.random() * Math.pow(10, 3)); - return date + extra; -} -exports.payloadId = payloadId; -function formatJsonRpcRequest(method, params, id) { - return { - id: id || payloadId(), - jsonrpc: "2.0", - method, - params, - }; -} -exports.formatJsonRpcRequest = formatJsonRpcRequest; -function formatJsonRpcResult(id, result) { - return { - id, - jsonrpc: "2.0", - result, - }; -} -exports.formatJsonRpcResult = formatJsonRpcResult; -//# sourceMappingURL=jsonRpcUtils.js.map \ No newline at end of file diff --git a/dist/src/jsonRpcUtils.js.map b/dist/src/jsonRpcUtils.js.map deleted file mode 100644 index 1e58baa..0000000 --- a/dist/src/jsonRpcUtils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"jsonRpcUtils.js","sourceRoot":"","sources":["../../src/jsonRpcUtils.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS;IACvB,MAAM,IAAI,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC;IAC1C,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;IAC1D,OAAO,IAAI,GAAG,KAAK,CAAC;AACtB,CAAC;AAJD,8BAIC;AAED,SAAgB,oBAAoB,CAClC,MAAc,EACd,MAAa,EACb,EAAW;IAEX,OAAO;QACL,EAAE,EAAE,EAAE,IAAI,SAAS,EAAE;QACrB,OAAO,EAAE,KAAK;QACd,MAAM;QACN,MAAM;KACP,CAAC;AACJ,CAAC;AAXD,oDAWC;AAED,SAAgB,mBAAmB,CACjC,EAAU,EACV,MAAW;IAEX,OAAO;QACL,EAAE;QACF,OAAO,EAAE,KAAK;QACd,MAAM;KACP,CAAC;AACJ,CAAC;AATD,kDASC"} \ No newline at end of file diff --git a/dist/src/provider.d.ts b/dist/src/provider.d.ts deleted file mode 100644 index 10cbc11..0000000 --- a/dist/src/provider.d.ts +++ /dev/null @@ -1,27 +0,0 @@ -import { BuildervaultProviderConfig, RequestArguments } from "./types"; -declare const HttpProvider: any; -export declare class BuildervaultWeb3Provider extends HttpProvider { - private config; - private headers; - private accountsAddresses; - private accountId; - private accountsPopulatedPromise; - private chainIdPopulatedPromise; - private requestCounter; - constructor(config: BuildervaultProviderConfig); - private populateChainId; - private populateAccounts; - private initialized; - send(payload: any, callback: (error: any, response: any) => void): void; - private createError; - sendAsync(payload: any, callback: (error: any, response: any) => void): void; - request(args: RequestArguments): Promise; - private sendTransaction; - private createPersonalSign; - private createTypedDataSign; - private structHash; - private typeHash; - private signTx; -} -export {}; -//# sourceMappingURL=provider.d.ts.map \ No newline at end of file diff --git a/dist/src/provider.d.ts.map b/dist/src/provider.d.ts.map deleted file mode 100644 index 3c2b5ef..0000000 --- a/dist/src/provider.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"provider.d.ts","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":"AAQA,OAAO,EAAoB,0BAA0B,EAAuC,gBAAgB,EAAI,MAAM,SAAS,CAAC;AAIhI,QAAA,MAAM,YAAY,KAAiC,CAAC;AAIpD,qBAAa,wBAAyB,SAAQ,YAAY;IACxD,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,OAAO,CAAyC;IACxD,OAAO,CAAC,iBAAiB,CAAwB;IACjD,OAAO,CAAC,SAAS,CAAS;IAC1B,OAAO,CAAC,wBAAwB,CAAsB;IACtD,OAAO,CAAC,uBAAuB,CAAsB;IACrD,OAAO,CAAC,cAAc,CAAK;gBAEf,MAAM,EAAE,0BAA0B;YA+BhC,eAAe;YAKf,gBAAgB;YAgFhB,WAAW;IAWlB,IAAI,CACT,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,KAAK,IAAI,GAC5C,IAAI;IAuEP,OAAO,CAAC,WAAW;IAcZ,SAAS,CACd,OAAO,EAAE,GAAG,EACZ,QAAQ,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,KAAK,IAAI,GAC5C,IAAI;IAIM,OAAO,CAClB,IAAI,EAAE,gBAAgB,GACrB,OAAO,CAAC,GAAG,CAAC;YAKD,eAAe;YA8Df,kBAAkB;YAiBlB,mBAAmB;YAwBnB,UAAU;YAuCV,QAAQ;YA+BR,MAAM;CAkFrB"} \ No newline at end of file diff --git a/dist/src/provider.js b/dist/src/provider.js deleted file mode 100644 index e05b4fe..0000000 --- a/dist/src/provider.js +++ /dev/null @@ -1,391 +0,0 @@ -"use strict"; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.BuildervaultWeb3Provider = void 0; -const tsmsdkv2_1 = require("@sepior/tsmsdkv2"); -// @ts-ignore -const asn1_js_1 = __importDefault(require("asn1.js")); -const web3_utils_1 = require("web3-utils"); -const web3_eth_abi_1 = require("web3-eth-abi"); -const web3_eth_accounts_1 = require("web3-eth-accounts"); -const util_1 = __importDefault(require("util")); -const utils_1 = require("./utils"); -const constants_1 = require("./constants"); -const jsonRpcUtils_1 = require("./jsonRpcUtils"); -const debug_1 = __importDefault(require("debug")); -const HttpProvider = require("web3-providers-http"); -const logRequestsAndResponses = (0, debug_1.default)(constants_1.DEBUG_NAMESPACE_REQUESTS_AND_RESPONSES); -class BuildervaultWeb3Provider extends HttpProvider { - constructor(config) { - if (!config.rpcUrl) { - throw Error(`rpcUrl is required`); - } - const debugNamespaces = [process.env.DEBUG || '']; - if (config.logRequestsAndResponses) { - debugNamespaces.push(constants_1.DEBUG_NAMESPACE_REQUESTS_AND_RESPONSES); - } - debug_1.default.enable(debugNamespaces.join(',')); - const headers = []; - super(config.rpcUrl); - this.headers = []; - this.accountsAddresses = {}; - this.requestCounter = 0; - this.config = config; - this.masterKeyId = config.masterKeyId; - this.accountId = Number(config.accountId || 0); - this.addressIndex = Number(config.addressIndex || 0); - this.chainPath = new Uint32Array([44, 60, this.accountId, 0, this.addressIndex]); - this.accountsAddresses[this.accountId] = {}; - this.headers = headers; - this.note = 'Created by BuilderVault Web3 Provider'; - this.chainIdPopulatedPromise = (0, utils_1.promiseToFunction)(async () => { if (!this.chainId) - return await this.populateChainId(); }); - this.accountsPopulatedPromise = (0, utils_1.promiseToFunction)(async () => { return await this.populateAccounts(); }); - } - async populateChainId() { - const chainId = (await util_1.default.promisify(super.send).bind(this)((0, jsonRpcUtils_1.formatJsonRpcRequest)('eth_chainId', []))).result; - this.chainId = Number(chainId); - } - async populateAccounts() { - var _a; - if (((_a = this.accountsAddresses[0]) === null || _a === void 0 ? void 0 : _a[0]) !== undefined) { - throw this.createError({ message: "Accounts already populated" }); - } - let player0config; - if (this.config.player0ApiKey) { - player0config = await new tsmsdkv2_1.Configuration(this.config.player0Url); - await player0config.withAPIKeyAuthentication(this.config.player0ApiKey); - } - else { - throw new Error('player0ApiKey is required'); - } - let player1config; - if (this.config.player1ApiKey) { - player1config = await new tsmsdkv2_1.Configuration(this.config.player1Url); - await player1config.withAPIKeyAuthentication(this.config.player1ApiKey); - } - else { - throw new Error('player1ApiKey is required'); - } - const TSMClients = [ - await tsmsdkv2_1.TSMClient.withConfiguration(player0config), - await tsmsdkv2_1.TSMClient.withConfiguration(player1config) - ]; - // ToDo: include this.addressIndex in loop when outside 0-5 - for (let i = 0; i < 5; i++) { - let chainPath = new Uint32Array([44, 60, this.accountId, 0, i]); - const pkixPublicKeys = []; - for (const [_, client] of TSMClients.entries()) { - const ecdsaApi = client.ECDSA(); - pkixPublicKeys.push(await ecdsaApi.publicKey(this.masterKeyId, chainPath)); - } - // Validate public keys - for (let i = 1; i < pkixPublicKeys.length; i++) { - if (Buffer.compare(pkixPublicKeys[0], pkixPublicKeys[i]) !== 0) { - throw Error("public keys do not match"); - } - } - const pkixPublicKey = pkixPublicKeys[0]; - // Convert the public key into an Ethereum address - const utils = TSMClients[0].Utils(); - const publicKeyBytes = await utils.pkixPublicKeyToUncompressedPoint(pkixPublicKey); - // Convert web3 publickey to address - var publicKeyHex = (0, web3_utils_1.toHex)(publicKeyBytes); - // Remove '0x' prefox - if (publicKeyHex.startsWith('0x')) { - publicKeyHex = publicKeyHex.slice(2); - } - // Remove the leading '04' byte (which signifies an uncompressed public key) - if (publicKeyHex.startsWith('04')) { - publicKeyHex = publicKeyHex.slice(2); - } - // Compute the keccak256 hash of the public key - const addressBuffer = (0, web3_utils_1.keccak256)(Buffer.from(publicKeyHex, 'hex')); - // Take the last 20 bytes of the hash, prefix it with '0x', and convert to string - const depositAddress = (0, web3_utils_1.toChecksumAddress)('0x' + addressBuffer.slice(-40)); - this.accountsAddresses[this.accountId][i] = depositAddress; - } - } - async initialized() { - // ToDo: check master key exists - await Promise.all([ - this.chainIdPopulatedPromise(), - this.accountsPopulatedPromise(), - ]); - } - send(payload, callback) { - (async () => { - var _a, _b, _c, _d, _e, _f; - let result; - let error = null; - const requestNumber = ++this.requestCounter; - try { - logRequestsAndResponses(`Request #${requestNumber}: method=${payload.method} params=${JSON.stringify(payload.params, undefined, 4)}`); - if (((_b = (_a = payload === null || payload === void 0 ? void 0 : payload.params) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.input) && !((_d = (_c = payload === null || payload === void 0 ? void 0 : payload.params) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.data)) { - payload.params[0].data = (_e = payload.params) === null || _e === void 0 ? void 0 : _e[0].input; - (_f = payload.params) === null || _f === void 0 ? true : delete _f[0].input; - } - switch (payload.method) { - case "eth_requestAccounts": - case "eth_accounts": - await this.accountsPopulatedPromise(); - result = Object.values(this.accountsAddresses[this.accountId]).map((address) => address); - break; - case "eth_sendTransaction": - try { - result = await this.sendTransaction(payload.params[0]); - } - catch (error) { - throw error; - } - break; - case "personal_sign": - case "eth_sign": - result = await this.createPersonalSign(payload.params[1], payload.params[0]); - break; - case "eth_signTypedData": - case "eth_signTypedData_v1": - case "eth_signTypedData_v3": - case "eth_signTypedData_v4": - result = await this.createTypedDataSign(payload.params[0], payload.params[1]); - break; - case "eth_signTypedData_v2": - case "eth_signTransaction": - default: - const jsonRpcResponse = await util_1.default.promisify(super.send).bind(this)(payload); - if (jsonRpcResponse.error) { - throw this.createError({ - message: jsonRpcResponse.error.message, - code: jsonRpcResponse.error.code, - data: jsonRpcResponse.error.data, - payload, - }); - } - result = jsonRpcResponse.result; - } - } - catch (e) { - error = e; - } - if (error) { - logRequestsAndResponses(`Error #${requestNumber}: ${error}`); - } - else { - logRequestsAndResponses(`Response #${requestNumber}: ${JSON.stringify(result, undefined, 4)}`); - } - callback(error, (0, jsonRpcUtils_1.formatJsonRpcResult)(payload.id, result)); - })(); - } - createError(errorData) { - const error = new Error(errorData.message); - error.code = errorData.code || -32603; - error.data = errorData.data; - error.payload = errorData.payload; - // We do this to avoid including this function in the stack trace - if (Error.captureStackTrace !== undefined) { - Error.captureStackTrace(error, this.createError); - } - return error; - } - sendAsync(payload, callback) { - this.send(payload, callback); - } - async request(args) { - return (await util_1.default.promisify(this.send).bind(this)((0, jsonRpcUtils_1.formatJsonRpcRequest)(args.method, args.params))).result; - } - async sendTransaction(transaction) { - await this.initialized(); - if (transaction.chainId == undefined) { - transaction.chainId = this.chainId; - } - else { - if (Number(transaction.chainId) != Number(this.chainId)) { - throw this.createError({ message: `Chain ID of the transaction (${transaction.chainId}) does not match the chain ID of the BuildervaultWeb3Provider (${this.chainId})` }); - } - } - if (transaction.from != this.accountsAddresses[this.accountId][this.addressIndex]) { - throw this.createError({ message: `Transaction sent from an unsupported address: ${transaction.from}` }); - } - if (transaction.nonce == undefined) { - let args = { - method: 'eth_getTransactionCount', - params: [transaction.from, "pending"] - }; - const nonce = await this.request(args); - transaction.nonce = (0, web3_utils_1.hexToNumber)(nonce); - } - if (transaction.type == undefined) { - transaction.type = 2; - } - if (transaction.gasLimit == undefined) { - let args = { - method: 'eth_estimateGas', - params: [{ - from: transaction.from, - to: transaction.to, - value: transaction.value, - data: transaction.data - }] - }; - const gasLimit = await this.request(args); - transaction.gasLimit = (0, web3_utils_1.hexToNumber)(gasLimit); - } - // ToDo maxFeePerGas and maxPriorityFeePerGas - const unsignedTx = web3_eth_accounts_1.FeeMarketEIP1559Transaction.fromTxData(transaction); - const unsignedTxHash = unsignedTx.getMessageToSign(true); - console.log('Raw unisgned transaction:', (0, web3_utils_1.toHex)(unsignedTx.serialize())); - const { r, s, v } = await this.signTx(unsignedTxHash, this.masterKeyId, this.chainPath); - const signedTransaction = unsignedTx._processSignature(v.valueOf(), (0, web3_utils_1.hexToBytes)(r), (0, web3_utils_1.hexToBytes)(s)); - const serializeTx = web3_eth_accounts_1.FeeMarketEIP1559Transaction.fromTxData(signedTransaction).serialize(); - console.log('Broadcasting signed transaction:', (0, web3_utils_1.toHex)(serializeTx)); - let args = { - method: 'eth_sendRawTransaction', - params: [(0, web3_utils_1.toHex)(serializeTx)] - }; - const signedTxHash = this.request(args); - return signedTxHash; - } - async createPersonalSign(address, content) { - await this.initialized(); - //ToDo look up address - if (address != this.accountsAddresses[this.accountId][this.addressIndex]) { - throw this.createError({ message: `Signature request from an unsupported address: ${address}` }); - } - // https://ethereum.org/en/developers/docs/apis/json-rpc/#eth_sign - const message = (0, web3_utils_1.hexToString)(content); - const messageHashBytes = (0, web3_utils_1.hexToBytes)((0, web3_eth_accounts_1.hashMessage)(message)); - const signature = await this.signTx(messageHashBytes, this.masterKeyId, this.chainPath); - return signature.r + signature.s.slice(2) + signature.v.toString(16); - } - async createTypedDataSign(address, content) { - await this.initialized(); - //ToDo look up address - if (address != this.accountsAddresses[this.accountId][this.addressIndex]) { - throw this.createError({ message: `Signature request from an unsupported address: ${address}` }); - } - const domainSeparator = this.structHash('EIP712Domain', content.domain); - const message = content.message; - const messageHash = (0, web3_utils_1.keccak256)(Buffer.concat([ - Buffer.from('1901', 'hex'), - domainSeparator, - this.structHash(content.primaryType, message), - ])); - const messageHashBytes = (0, web3_utils_1.hexToBytes)(messageHash); - const signature = await this.signTx(messageHashBytes, this.masterKeyId, this.chainPath); - return signature.r + signature.s.slice(2) + signature.v.toString(16); - } - async structHash(primaryType, data) { - const types = { - EIP712Domain: [ - { name: 'name', type: 'string' }, - { name: 'version', type: 'string' }, - { name: 'chainId', type: 'uint256' }, - { name: 'verifyingContract', type: 'address' }, - ], - }; - const encTypes = []; - const encValues = []; - // Add typehash - encTypes.push('bytes32'); - encValues.push(this.typeHash(primaryType)); - // Add field contents - for (const field of types[primaryType]) { - const value = data[field.name]; - if (field.type == 'string' || field.type == 'bytes') { - encTypes.push('bytes32'); - const valueHash = (0, web3_utils_1.keccak256)(value); - encValues.push(valueHash); - } - else if (types[field.type] !== undefined) { - encTypes.push('bytes32'); - const valueHash = await this.structHash(field.type, value); - encValues.push(valueHash); - } - else if (field.type.lastIndexOf(']') === field.type.length - 1) { - throw 'TODO: Arrays currently unimplemented in encodeData'; - } - else { - encTypes.push(field.type); - encValues.push(value); - } - } - return (0, web3_utils_1.keccak256)((0, web3_eth_abi_1.encodeParameter)(encTypes, encValues)); - } - async typeHash(primaryType) { - const types = { - EIP712Domain: [ - { name: 'name', type: 'string' }, - { name: 'version', type: 'string' }, - { name: 'chainId', type: 'uint256' }, - { name: 'verifyingContract', type: 'address' }, - ], - }; - const typeList = [primaryType]; - const typeHashList = []; - while (typeList.length > 0) { - const type = typeList.shift(); - const typeHash = (0, web3_utils_1.keccak256)(Buffer.from(type)); - typeHashList.push(typeHash); - if (types[type]) { - for (const field of types[type]) { - if (types[field.type]) { - typeList.push(field.type); - } - } - } - } - return (0, web3_utils_1.keccak256)((0, web3_eth_abi_1.encodeParameter)('bytes32[]', [typeHashList])); - } - async signTx(messageToSign, masterKeyId, chainPath) { - console.log(`Builder Vault signing transaction hash...`); - let player0config; - if (this.config.player0ApiKey) { - player0config = await new tsmsdkv2_1.Configuration(this.config.player0Url); - await player0config.withAPIKeyAuthentication(this.config.player0ApiKey); - } - else { - throw new Error('player0ApiKey is required'); - } - let player1config; - if (this.config.player1ApiKey) { - player1config = await new tsmsdkv2_1.Configuration(this.config.player1Url); - await player1config.withAPIKeyAuthentication(this.config.player1ApiKey); - } - else { - throw new Error('player1ApiKey is required'); - } - const clients = [ - await tsmsdkv2_1.TSMClient.withConfiguration(player0config), - await tsmsdkv2_1.TSMClient.withConfiguration(player1config) - ]; - const sessionConfig = await tsmsdkv2_1.SessionConfig.newStaticSessionConfig(await tsmsdkv2_1.SessionConfig.GenerateSessionID(), clients.length); - const partialSignatures = []; - const partialSignaturePromises = []; - for (const [_, client] of clients.entries()) { - const func = async () => { - const ecdsaApi = client.ECDSA(); - console.log(`Creating partialSignature with MPC player ${_}...`); - const partialSignResult = await ecdsaApi.sign(sessionConfig, masterKeyId, chainPath, messageToSign); - partialSignatures.push(partialSignResult); - }; - partialSignaturePromises.push(func()); - } - await Promise.all(partialSignaturePromises); - const ecdsaApi = clients[0].ECDSA(); - const signature = await ecdsaApi.finalizeSignature(messageToSign, partialSignatures); - // Define ASN.1 structure for decoding - const ASN1Signature = asn1_js_1.default.define("Signature", function () { - this.seq().obj(this.key("r").int(), this.key("s").int()); - }); - const decodedSignature = ASN1Signature.decode(Buffer.from(signature.signature)); - return { - r: "0x" + decodedSignature.r.toString(16), - s: "0x" + decodedSignature.s.toString(16), - v: BigInt(signature.recoveryID + 27), // Type 2 transaction with ._processSignature subtracts 27 Post EIP-155 should be: chainId * 2 + 35 + signature.recoveryID; - }; - } -} -exports.BuildervaultWeb3Provider = BuildervaultWeb3Provider; -//# sourceMappingURL=provider.js.map \ No newline at end of file diff --git a/dist/src/provider.js.map b/dist/src/provider.js.map deleted file mode 100644 index e9e305e..0000000 --- a/dist/src/provider.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"provider.js","sourceRoot":"","sources":["../../src/provider.ts"],"names":[],"mappings":";;;;;;AAAA,+CAA2E;AAC3E,aAAa;AACb,sDAA2B;AAC3B,2CAAiI;AACjI,+CAA+C;AAC/C,yDAA6E;AAC7E,gDAAwB;AACxB,mCAA4C;AAE5C,2CAAqE;AACrE,iDAA2E;AAC3E,kDAA0B;AAC1B,MAAM,YAAY,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAC;AACpD,MAAM,uBAAuB,GAAG,IAAA,eAAK,EAAC,kDAAsC,CAAC,CAAC;AAG9E,MAAa,wBAAyB,SAAQ,YAAY;IASxD,YAAY,MAAkC;QAC5C,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE;YAClB,MAAM,KAAK,CAAC,oBAAoB,CAAC,CAAC;SACnC;QAED,MAAM,eAAe,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAA;QACjD,IAAI,MAAM,CAAC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CAAC;YACzC,CAAC,EAAE,MAAM,CAAC,SAAS,CAAC,UAAW,GAAG,EAAE,CAAC,EAAG,4HAA4H;SACrK,CAAC;IACJ,CAAC;CAEF;AA7eD,4DA6eC"} \ No newline at end of file diff --git a/dist/src/tests/utils.d.ts b/dist/src/tests/utils.d.ts deleted file mode 100644 index 6e32d3f..0000000 --- a/dist/src/tests/utils.d.ts +++ /dev/null @@ -1,7 +0,0 @@ -import * as ethers from "ethers"; -import { BuildervaultWeb3Provider } from ".."; -import Web3 from "web3"; -export declare function getBuildervaultProviderForTesting(extraConfiguration?: any): BuildervaultWeb3Provider; -export declare function getEthersBuildervaultProviderForTesting(extraConfiguration?: any): ethers.ethers.providers.Web3Provider; -export declare function getWeb3BuildervaultProviderForTesting(extraConfiguration?: any): Web3; -//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/dist/src/tests/utils.d.ts.map b/dist/src/tests/utils.d.ts.map deleted file mode 100644 index d207594..0000000 --- a/dist/src/tests/utils.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../src/tests/utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAA;AAChC,OAAO,EAAE,wBAAwB,EAAE,MAAM,IAAI,CAAA;AAC7C,OAAO,IAAI,MAAM,MAAM,CAAC;AAExB,wBAAgB,iCAAiC,CAAC,kBAAkB,CAAC,EAAE,GAAG,4BA2BzE;AAED,wBAAgB,uCAAuC,CAAC,kBAAkB,CAAC,EAAE,GAAG,wCAE/E;AAED,wBAAgB,qCAAqC,CAAC,kBAAkB,CAAC,EAAE,GAAG,mDAE7E"} \ No newline at end of file diff --git a/dist/src/tests/utils.js b/dist/src/tests/utils.js deleted file mode 100644 index 78db072..0000000 --- a/dist/src/tests/utils.js +++ /dev/null @@ -1,57 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -var __importDefault = (this && this.__importDefault) || function (mod) { - return (mod && mod.__esModule) ? mod : { "default": mod }; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.getWeb3BuildervaultProviderForTesting = exports.getEthersBuildervaultProviderForTesting = exports.getBuildervaultProviderForTesting = void 0; -const dotenv = __importStar(require("dotenv")); -dotenv.config(); -const ethers = __importStar(require("ethers")); -const __1 = require(".."); -const web3_1 = __importDefault(require("web3")); -function getBuildervaultProviderForTesting(extraConfiguration) { - if (!process.env.BLOCKDAEMON_RPC_URL || - !process.env.BUILDERVAULT_PLAYER0_URL || - !process.env.BUILDERVAULT_PLAYER0_APIKEY || - !process.env.BUILDERVAULT_PLAYER1_URL || - !process.env.BUILDERVAULT_PLAYER1_APIKEY || - !process.env.BUILDERVAULT_MASTERKEY_ID) { - throw new Error("Environment variables BLOCKDAEMON_RPC_URL, BUILDERVAULT_PLAYER0_URL, BUILDERVAULT_PLAYER0_APIKEY must be set"); - } - const providerConfig = Object.assign({ rpcUrl: process.env.BLOCKDAEMON_RPC_URL, player0Url: process.env.BUILDERVAULT_PLAYER0_URL, player0ApiKey: process.env.BUILDERVAULT_PLAYER0_APIKEY, player1Url: process.env.BUILDERVAULT_PLAYER1_URL, player1ApiKey: process.env.BUILDERVAULT_PLAYER1_APIKEY, masterKeyId: process.env.BUILDERVAULT_MASTERKEY_ID, accountId: process.env.BUILDERVAULT_ACCOUNT_ID, addressIndex: process.env.BUILDERVAULT_ADDRESS_INDEX, logRequestsAndResponses: true }, extraConfiguration); - const provider = new __1.BuildervaultWeb3Provider(providerConfig); - return provider; -} -exports.getBuildervaultProviderForTesting = getBuildervaultProviderForTesting; -function getEthersBuildervaultProviderForTesting(extraConfiguration) { - return new ethers.providers.Web3Provider(getBuildervaultProviderForTesting(extraConfiguration)); -} -exports.getEthersBuildervaultProviderForTesting = getEthersBuildervaultProviderForTesting; -function getWeb3BuildervaultProviderForTesting(extraConfiguration) { - return new web3_1.default(getBuildervaultProviderForTesting(extraConfiguration)); -} -exports.getWeb3BuildervaultProviderForTesting = getWeb3BuildervaultProviderForTesting; -//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/dist/src/tests/utils.js.map b/dist/src/tests/utils.js.map deleted file mode 100644 index d6c30a6..0000000 --- a/dist/src/tests/utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../src/tests/utils.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,+CAAgC;AAChC,MAAM,CAAC,MAAM,EAAE,CAAA;AACf,+CAAgC;AAChC,0BAA6C;AAC7C,gDAAwB;AAExB,SAAgB,iCAAiC,CAAC,kBAAwB;IACxE,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,mBAAmB;QAClC,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB;QACrC,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B;QACxC,CAAC,OAAO,CAAC,GAAG,CAAC,wBAAwB;QACrC,CAAC,OAAO,CAAC,GAAG,CAAC,2BAA2B;QACxC,CAAC,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAAE;QACxC,MAAM,IAAI,KAAK,CAAC,8GAA8G,CAAC,CAAA;KAChI;IAED,MAAM,cAAc,mBAClB,MAAM,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB,EACvC,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAChD,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,2BAA2B,EACtD,UAAU,EAAE,OAAO,CAAC,GAAG,CAAC,wBAAwB,EAChD,aAAa,EAAE,OAAO,CAAC,GAAG,CAAC,2BAA2B,EACtD,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB,EAClD,SAAS,EAAE,OAAO,CAAC,GAAG,CAAC,uBAAuB,EAC9C,YAAY,EAAE,OAAO,CAAC,GAAG,CAAC,0BAA0B,EACpD,uBAAuB,EAAE,IAAI,IAC1B,kBAAkB,CACtB,CAAC;IAGF,MAAM,QAAQ,GAAG,IAAI,4BAAwB,CAAC,cAAc,CAAC,CAAA;IAE7D,OAAO,QAAQ,CAAA;AACjB,CAAC;AA3BD,8EA2BC;AAED,SAAgB,uCAAuC,CAAC,kBAAwB;IAC9E,OAAO,IAAI,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,iCAAiC,CAAC,kBAAkB,CAAC,CAAC,CAAA;AACjG,CAAC;AAFD,0FAEC;AAED,SAAgB,qCAAqC,CAAC,kBAAwB;IAC5E,OAAO,IAAI,cAAI,CAAC,iCAAiC,CAAC,kBAAkB,CAAC,CAAC,CAAA;AACxE,CAAC;AAFD,sFAEC"} \ No newline at end of file diff --git a/dist/src/tests/web3/contractCall.test.d.ts b/dist/src/tests/web3/contractCall.test.d.ts deleted file mode 100644 index 1b1fb10..0000000 --- a/dist/src/tests/web3/contractCall.test.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export {}; -//# sourceMappingURL=contractCall.test.d.ts.map \ No newline at end of file diff --git a/dist/src/tests/web3/contractCall.test.d.ts.map b/dist/src/tests/web3/contractCall.test.d.ts.map deleted file mode 100644 index b81a171..0000000 --- a/dist/src/tests/web3/contractCall.test.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"contractCall.test.d.ts","sourceRoot":"","sources":["../../../../src/tests/web3/contractCall.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/src/tests/web3/contractCall.test.js b/dist/src/tests/web3/contractCall.test.js deleted file mode 100644 index d4b747f..0000000 --- a/dist/src/tests/web3/contractCall.test.js +++ /dev/null @@ -1,59 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -const vitest_1 = require("vitest"); -const utils_1 = require("../utils"); -const GREETER_ADDRESS = "0x432d810484AdD7454ddb3b5311f0Ac2E95CeceA8"; // Holesky -const GREETER_ABI = [ - { - "type": "function", - "name": "greet", - "inputs": [], - "outputs": [ - { - "internalType": "string", - "name": "", - "type": "string" - } - ] - }, - { - "type": "function", - "name": "setGreeting", - "inputs": [ - { - "internalType": "string", - "name": "_greeting", - "type": "string" - } - ], - "outputs": [] - } -]; -const provider = (0, utils_1.getWeb3BuildervaultProviderForTesting)(); -const greeting = (new Date()).toISOString(); -const greeterContract = new provider.eth.Contract(GREETER_ABI, GREETER_ADDRESS); -async function getFirstAddressWithBalance() { - const addresses = await provider.eth.getAccounts(); - for (const address of addresses) { - const balance = await provider.eth.getBalance(address); - if (BigInt(balance) > BigInt(provider.utils.toWei('0.01', 'ether'))) { - return address; - } - } - throw new Error(`No vault has balance`); -} -(0, vitest_1.describe)("Web3: Should be able to call a contract method", () => { - (0, vitest_1.it)("greet() before", async () => { - const currentGreeting = await greeterContract.methods.greet().call(); - (0, vitest_1.expect)(currentGreeting).to.not.be.equal(greeting); - }); - (0, vitest_1.it)("setGreeting(greeting)", async () => { - const receipt = await greeterContract.methods.setGreeting(greeting).send({ from: await getFirstAddressWithBalance() }); - (0, vitest_1.expect)(receipt.transactionHash).to.be.not.undefined; - }); - (0, vitest_1.it)("greet() after", async () => { - const currentGreeting = await greeterContract.methods.greet().call(); - (0, vitest_1.expect)(currentGreeting).to.be.equal(greeting); - }); -}); -//# sourceMappingURL=contractCall.test.js.map \ No newline at end of file diff --git a/dist/src/tests/web3/contractCall.test.js.map b/dist/src/tests/web3/contractCall.test.js.map deleted file mode 100644 index b4f8196..0000000 --- a/dist/src/tests/web3/contractCall.test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"contractCall.test.js","sourceRoot":"","sources":["../../../../src/tests/web3/contractCall.test.ts"],"names":[],"mappings":";;AAAA,mCAA6C;AAC7C,oCAAgE;AAEhE,MAAM,eAAe,GAAG,4CAA4C,CAAA,CAAE,UAAU;AAChF,MAAM,WAAW,GAAG;IAClB;QACE,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,OAAO;QACf,QAAQ,EAAE,EAAE;QACZ,SAAS,EAAE;YACT;gBACE,cAAc,EAAE,QAAQ;gBACxB,MAAM,EAAE,EAAE;gBACV,MAAM,EAAE,QAAQ;aACjB;SACF;KACF;IACD;QACE,MAAM,EAAE,UAAU;QAClB,MAAM,EAAE,aAAa;QACrB,QAAQ,EAAE;YACR;gBACE,cAAc,EAAE,QAAQ;gBACxB,MAAM,EAAE,WAAW;gBACnB,MAAM,EAAE,QAAQ;aACjB;SACF;QACD,SAAS,EAAE,EAAE;KACd;CACO,CAAA;AACV,MAAM,QAAQ,GAAG,IAAA,6CAAqC,GAAE,CAAA;AACxD,MAAM,QAAQ,GAAG,CAAC,IAAI,IAAI,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;AAC3C,MAAM,eAAe,GAAG,IAAI,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,WAAW,EAAE,eAAe,CAAC,CAAA;AAE/E,KAAK,UAAU,0BAA0B;IACvC,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,WAAW,EAAE,CAAA;IAClD,KAAK,MAAM,OAAO,IAAI,SAAS,EAAE;QAC/B,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAC,GAAG,CAAC,UAAU,CAAC,OAAO,CAAC,CAAA;QACtD,IAAI,MA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3/sign.test.d.ts deleted file mode 100644 index 238f3c7..0000000 --- a/dist/src/tests/web3/sign.test.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export {}; -//# sourceMappingURL=sign.test.d.ts.map \ No newline at end of file diff --git a/dist/src/tests/web3/sign.test.d.ts.map b/dist/src/tests/web3/sign.test.d.ts.map deleted file mode 100644 index 99c43ad..0000000 --- a/dist/src/tests/web3/sign.test.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"sign.test.d.ts","sourceRoot":"","sources":["../../../../src/tests/web3/sign.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/src/tests/web3/sign.test.js b/dist/src/tests/web3/sign.test.js deleted file mode 100644 index 5a5b0b2..0000000 --- a/dist/src/tests/web3/sign.test.js +++ /dev/null @@ -1,106 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const vitest_1 = require("vitest"); -const ethers = __importStar(require("ethers")); -const web3_eth_accounts_1 = require("web3-eth-accounts"); -const utils_1 = require("../utils"); -const NULL_ADDRESS = "0x0000000000000000000000000000000000000000"; -const web3 = (0, utils_1.getWeb3BuildervaultProviderForTesting)(); -(0, vitest_1.describe)("Web3: Should be able to sign using BuilderVault", () => { - (0, vitest_1.it)("signMessage", async () => { - // ToDo: add pause - const message = "hello world"; - const signerAddress = (await web3.eth.getAccounts())[0]; - const signature = await web3.eth.personal.sign(message, signerAddress, ""); - const recoveredAddress = await (0, web3_eth_accounts_1.recover)(message, signature); - //const recoveredAddress = ethers.utils.verifyMessage(message, signature) - (0, vitest_1.expect)(recoveredAddress).to.be.equals(signerAddress); - }); - (0, vitest_1.it)("eth_signTypedData_v4", async () => { - var _a; - const signerAddress = (await web3.eth.getAccounts())[0]; - const domain = { - name: "FAKE Coin", - version: "0", - chainId: 0, - verifyingContract: NULL_ADDRESS - }; - const types = { - Permit: [ - { - name: "owner", - type: "address" - }, - { - name: "spender", - type: "address" - }, - { - name: "value", - type: "uint256" - }, - { - name: "nonce", - type: "uint256" - }, - { - name: "deadline", - type: "uint256" - } - ], - EIP712Domain: [ - { name: 'name', type: 'string' }, - { name: 'version', type: 'string' }, - { name: 'chainId', type: 'uint256' }, - { name: 'verifyingContract', type: 'address' }, - ], - }; - const message = { - owner: NULL_ADDRESS, - spender: NULL_ADDRESS, - value: 1, - nonce: 1, - deadline: 1 - }; - const primaryType = "Permit"; - const data = { - types, - domain, - message, - primaryType, - }; - const signature = await ((_a = web3.currentProvider) === null || _a === void 0 ? void 0 : _a.request({ - method: "eth_signTypedData_v4", - params: [signerAddress, data], - })); - //const signature = await web3.eth.signTypedData(signerAddress, data, false) - // @ts-ignore - delete types.EIP712Domain; - const recoveredAddress = ethers.utils.verifyTypedData(domain, types, message, signature); - (0, vitest_1.expect)(recoveredAddress).to.be.equals(signerAddress); - }); -}); -//# sourceMappingURL=sign.test.js.map \ No newline at end of file diff --git a/dist/src/tests/web3/sign.test.js.map b/dist/src/tests/web3/sign.test.js.map deleted file mode 100644 index b1829dc..0000000 --- a/dist/src/tests/web3/sign.test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"sign.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CAAC,EAAE,CAAC,MAAM,CAAC,aAAa,CAAC,CAAA;IACtD,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/src/tests/web3/transfer.test.d.ts b/dist/src/tests/web3/transfer.test.d.ts deleted file mode 100644 index 1567ed3..0000000 --- a/dist/src/tests/web3/transfer.test.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export {}; -//# sourceMappingURL=transfer.test.d.ts.map \ No newline at end of file diff --git a/dist/src/tests/web3/transfer.test.d.ts.map b/dist/src/tests/web3/transfer.test.d.ts.map deleted file mode 100644 index 68aa3c6..0000000 --- a/dist/src/tests/web3/transfer.test.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"transfer.test.d.ts","sourceRoot":"","sources":["../../../../src/tests/web3/transfer.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/src/tests/web3/transfer.test.js b/dist/src/tests/web3/transfer.test.js deleted file mode 100644 index 3afc40e..0000000 --- a/dist/src/tests/web3/transfer.test.js +++ /dev/null @@ -1,66 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -const vitest_1 = require("vitest"); -const ethers = __importStar(require("ethers")); -const utils_1 = require("../utils"); -const transferAmount = ethers.utils.parseEther("0.00000000001").toString(); -const minAmount = ethers.utils.parseEther("0.001").toString(); -const web3 = (0, utils_1.getWeb3BuildervaultProviderForTesting)(); -async function getFirstAddressWithBalance() { - const addresses = await web3.eth.getAccounts(); - for (const address of addresses) { - const balance = await web3.eth.getBalance(address); - if (BigInt(balance) > BigInt(minAmount)) { - return address.toLowerCase(); - } - } - throw new Error(`No vault has balance greater than ${transferAmount.toString()}`); -} -(0, vitest_1.describe)("Web3: Should be able to transfer ETH", async function () { - (0, vitest_1.it)("Transfer", async function () { - const addresses = await web3.eth.getAccounts(); - //const fromAddress = await getFirstAddressWithBalance() - const fromAddress = (await web3.eth.getAccounts())[0]; - const toAddress = addresses.find(x => x != fromAddress); - if (!toAddress) { - throw new Error('No toAddress found'); - } - const toAddressStartingBalance = await web3.eth.getBalance(toAddress); - const feeData = await web3.eth.calculateFeeData(); - await web3.eth.sendTransaction({ - chainId: await web3.eth.getChainId(), - from: fromAddress, - to: toAddress, - value: transferAmount, - //gasLimit: 21000, - maxFeePerGas: feeData.maxFeePerGas, - maxPriorityFeePerGas: feeData.maxPriorityFeePerGas, - }); - const toAddressEndingBalance = await web3.eth.getBalance(toAddress); - (0, vitest_1.expect)(BigInt(toAddressEndingBalance) == (BigInt(toAddressStartingBalance) - BigInt(transferAmount))); - }); -}); -//# sourceMappingURL=transfer.test.js.map \ No newline at end of file diff --git a/dist/src/tests/web3/transfer.test.js.map b/dist/src/tests/web3/transfer.test.js.map deleted file mode 100644 index afefddb..0000000 --- a/dist/src/tests/web3/transfer.test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"transfer.test.js","sourceRoot":"","sources":["../../../../src/tests/web3/transfer.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAiD;AACjD,+CAAgC;AAChC,oCAAgE;AAEhE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CAAC,CAAA;QACrE,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,gBAAgB,EAAE,CAAC;QAElD,MAAM,IAAI,CAAC,GAAG,CAAC,eAAe,CAAC;YAC7B,OAAO,EAAE,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE;YACpC,IAAI,EAAE,WAAW;YACjB,EAAE,EAAE,SAAS;YACb,KAAK,EAAE,cAAc;YACrB,kBAAkB;YAClB,YAAY,EAAE,OAAO,CAAC,YAAY;YAClC,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;SACnD,CAAC,CAAA;QAEF,MAAM,sBAAsB,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,SAAS,CAAC,CAAA;QAEnE,IAAA,eAAM,EAAC,MAAM,CAAC,sBAAsB,CAAC,IAAI,CAAC,MAAM,CAAC,wBAAwB,CAAC,GAAG,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,CAAA;IACvG,CAAC,CAAC,CAAA;AACJ,CAAC,CAAC,CAAA"} \ No newline at end of file diff --git a/dist/src/types.d.ts b/dist/src/types.d.ts deleted file mode 100644 index 5ef7b13..0000000 --- a/dist/src/types.d.ts +++ /dev/null @@ -1,57 +0,0 @@ -export declare type BuildervaultProviderConfig = { - /** - * Set the RPC API URL endpoint for JSON-RPC over HTTP access to the blockchain data - */ - rpcUrl?: string; - /** - * Set the URL of the BuilderVault player0 and player1 endpoints - */ - player0Url?: string; - player1Url?: string; - /** - * Set the BuilderVault TSM API keys - */ - player0ApiKey?: string; - player1ApiKey?: string; - /** - * BuilderVault Master Key ID. This ID represents all the private Master Key shares and must be generated outside if the web3 provider using the BuilderVault SDK - */ - masterKeyId?: string; - /** - * It is recommended to provide the account id explicitly. - * This represents the in the BIP44 chain path m/44/60/account/0/address_index - */ - accountId?: number; - /** - * By default, the first 5 addresses are derived from the master key - * It is recommended to provide the address index explicitly. - * This represents the in the BIP44 chain path m/44/60/account/0/address_index - */ - addressIndex?: number; - /** - * Default: false - * By setting to true, every request and response processed by the provider will be logged to the console - * Same as setting env var `DEBUG=buildervault-web3-provider:req_res` - */ - logRequestsAndResponses?: boolean; -}; -export declare type EthereumSignature = { - r: string; - s: string; - v: BigInt; -}; -export interface AccountAddresses { - [accountId: number]: { - [accountIndex: number]: string; - }; -} -export interface RequestArguments { - method: string; - params?: T; -} -export interface ProviderRpcError extends Error { - code: number; - data?: unknown; - payload: RequestArguments; -} -//# sourceMappingURL=types.d.ts.map \ No newline at end of file diff --git a/dist/src/types.d.ts.map b/dist/src/types.d.ts.map deleted file mode 100644 index 1badcf2..0000000 --- a/dist/src/types.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":"AACA,oBAAY,0BAA0B,GAAG;IAEvC;;OAEG;IACH,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;OAEG;IACH,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB;;OAEG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;;OAIG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;IAGtB;;;;OAIG;IACH,uBAAuB,CAAC,EAAE,OAAO,CAAC;CACnC,CAAA;AAED,oBAAY,iBAAiB,GAAG;IAC9B,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX,CAAC;AAEF,MAAM,WAAW,gBAAgB;IAC/B,CAAC,SAAS,EAAE,MAAM,GAAG;QACnB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM,CAAC;KAChC,CAAC;CACH;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,GAAG;IACvC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,CAAC,CAAC;CACZ;AAED,MAAM,WAAW,gBAAiB,SAAQ,KAAK;IAC7C,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,OAAO,EAAE,gBAAgB,CAAC;CAC3B"} \ No newline at end of file diff --git a/dist/src/types.js b/dist/src/types.js deleted file mode 100644 index 11e638d..0000000 --- a/dist/src/types.js +++ /dev/null @@ -1,3 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -//# sourceMappingURL=types.js.map \ No newline at end of file diff --git a/dist/src/types.js.map b/dist/src/types.js.map deleted file mode 100644 index 7b5fff8..0000000 --- a/dist/src/types.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/dist/src/utils.d.ts b/dist/src/utils.d.ts deleted file mode 100644 index ca3cb96..0000000 --- a/dist/src/utils.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export declare function promiseToFunction(func: () => Promise): () => Promise; -//# sourceMappingURL=utils.d.ts.map \ No newline at end of file diff --git a/dist/src/utils.d.ts.map b/dist/src/utils.d.ts.map deleted file mode 100644 index a22e8a6..0000000 --- a/dist/src/utils.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":"AACA,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAa/E"} \ No newline at end of file diff --git a/dist/src/utils.js b/dist/src/utils.js deleted file mode 100644 index f33bff5..0000000 --- a/dist/src/utils.js +++ /dev/null @@ -1,17 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.promiseToFunction = void 0; -function promiseToFunction(func) { - let exceptionThrown = false; - const promise = func().catch((e) => { - exceptionThrown = true; - return e; - }); - return async () => { - const result = await promise; - if (exceptionThrown) - throw result; - }; -} -exports.promiseToFunction = promiseToFunction; -//# sourceMappingURL=utils.js.map \ No newline at end of file diff --git a/dist/src/utils.js.map b/dist/src/utils.js.map deleted file mode 100644 index 3c1ad09..0000000 --- a/dist/src/utils.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../src/utils.ts"],"names":[],"mappings":";;;AACA,SAAgB,iBAAiB,CAAC,IAAwB;IACtD,IAAI,eAAe,GAAG,KAAK,CAAA;IAE3B,MAAM,OAAO,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE;QAC/B,eAAe,GAAG,IAAI,CAAA;QACtB,OAAO,CAAC,CAAA;IACZ,CAAC,CAAC,CAAC;IAEH,OAAO,KAAK,IAAI,EAAE;QACd,MAAM,MAAM,GAAG,MAAM,OAAO,CAAA;QAC5B,IAAI,eAAe;YACf,MAAM,MAAM,CAAA;IACpB,CAAC,CAAC;AACN,CAAC;AAbD,8CAaC"} \ No newline at end of file diff --git a/package.json b/package.json index 3dac512..1e1dca4 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,10 @@ "name": "@blockdaemon/buildervault-web3-provider", "version": "0.0.1", "description": "EIP-1193 Compatible Ethereum provider for BuilderVault", - "repository": "https://github.com/blockdaemon/buildervault-web3-provider.git", + "repository": { + "type": "git", + "url": "git+https://github.com/blockdaemon/buildervault-web3-provider.git" + }, "publishConfig": { "registry": "https://npm.pkg.github.com" }, @@ -17,6 +20,7 @@ }, "files": [ "dist/", + "src/", "README.md" ], "devDependencies": { diff --git a/tsconfig.json b/tsconfig.json index 0e9386e..22fbdd5 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,7 @@ "rootDirs": ["./src"], "esModuleInterop": true, "resolveJsonModule": true, + "skipLibCheck": true, }, "exclude": ["dist", "node_modules"], "include": [