From 8a0108656381079e223ca86442c998d92717d006 Mon Sep 17 00:00:00 2001 From: zxpectre <15870846+zxpectre@users.noreply.github.com> Date: Thu, 23 Jan 2025 16:51:15 -0300 Subject: [PATCH 1/3] feat: Bump CSL. Update for Plomin HF support --- package-lock.json | 11 ++++++----- package.json | 2 +- src/sync/cardano.ts | 4 ++-- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/package-lock.json b/package-lock.json index 796a2e9..157856c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -16,7 +16,7 @@ "devDependencies": { "@commitlint/cli": "^13.1.0", "@commitlint/config-conventional": "^13.1.0", - "@emurgo/cardano-serialization-lib-nodejs": "^11.5.0", + "@emurgo/cardano-serialization-lib-nodejs": "^13.2.1", "@jest/globals": "^29.7.0", "@types/crypto-js": "^4.2.2", "@types/jest": "^27.5.2", @@ -1123,10 +1123,11 @@ } }, "node_modules/@emurgo/cardano-serialization-lib-nodejs": { - "version": "11.5.0", - "resolved": "https://registry.npmjs.org/@emurgo/cardano-serialization-lib-nodejs/-/cardano-serialization-lib-nodejs-11.5.0.tgz", - "integrity": "sha512-IlVABlRgo9XaTR1NunwZpWcxnfEv04ba2l1vkUz4S1W7Jt36F4CtffP+jPeqBZGnAe+fnUwo0XjIJC3ZTNToNQ==", - "dev": true + "version": "13.2.1", + "resolved": "https://registry.npmjs.org/@emurgo/cardano-serialization-lib-nodejs/-/cardano-serialization-lib-nodejs-13.2.1.tgz", + "integrity": "sha512-0g2O3YHnoQbkHj5M8FB7ftnljXQ9M3zmKxZnwCbYGr1Pw4FkBA0BRh0+GHPlTxyemcpP2yyuW439I9Ds9drFhA==", + "dev": true, + "license": "MIT" }, "node_modules/@endemolshinegroup/cosmiconfig-typescript-loader": { "version": "3.0.2", diff --git a/package.json b/package.json index dc3e5e5..b913d79 100644 --- a/package.json +++ b/package.json @@ -65,7 +65,7 @@ "devDependencies": { "@commitlint/cli": "^13.1.0", "@commitlint/config-conventional": "^13.1.0", - "@emurgo/cardano-serialization-lib-nodejs": "^11.5.0", + "@emurgo/cardano-serialization-lib-nodejs": "^13.2.1", "@jest/globals": "^29.7.0", "@types/crypto-js": "^4.2.2", "@types/jest": "^27.5.2", diff --git a/src/sync/cardano.ts b/src/sync/cardano.ts index c95eaa0..6f76d81 100644 --- a/src/sync/cardano.ts +++ b/src/sync/cardano.ts @@ -228,7 +228,7 @@ export const cardanoValidatorsFactory=(CSL:any):UnimatrixValidatorMap=>({ try{ const txHex:string=args?.store.file?.data||""; const [dltTag,networkTag,txHash] = args.path||[]; - const txObj = CSL.Transaction.from_hex(txHex) //.from_bytes(fromHex(txHex)) + const txObj = CSL.FixedTransaction.from_hex(txHex) //.from_bytes(fromHex(txHex)) const txBodyObj = txObj.body() //args.CSL.TransactionBody.from_bytes(fromHex(txHex)) const networkId = txBodyObj.network_id()?.kind(); if(networkId!==undefined){ @@ -241,7 +241,7 @@ export const cardanoValidatorsFactory=(CSL:any):UnimatrixValidatorMap=>({ if(realNetworkTag!==networkTag) return `This is a '${realNetworkTag||"unknown network"}' transaction. Wrong network` } - const txHashObj = CSL.hash_transaction(txBodyObj); + const txHashObj = txObj.transaction_hash()//CSL.hash_transaction(txBodyObj); const realTxHash = txHashObj.to_hex(); if(realTxHash!==txHash) return "Transaction hash mismatch" From c3b28b6fc50a586ac4296be9d0680e37d0d7b55f Mon Sep 17 00:00:00 2001 From: zxpectre <15870846+zxpectre@users.noreply.github.com> Date: Thu, 23 Jan 2025 16:51:22 -0300 Subject: [PATCH 2/3] Bump CSL. Update for Plomin HF support --- package-lock.json | 4 ++-- package.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/package-lock.json b/package-lock.json index 157856c..17ef439 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@gamechanger-finance/unimatrix", - "version": "1.0.2", + "version": "1.0.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@gamechanger-finance/unimatrix", - "version": "1.0.2", + "version": "1.0.3", "hasInstallScript": true, "license": "LICENSE.md", "dependencies": { diff --git a/package.json b/package.json index b913d79..151e8b7 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@gamechanger-finance/unimatrix", - "version": "1.0.2", + "version": "1.0.3", "description": "Unimatrix Sync is a decentralized, privacy preserving, transaction witness sharing and pairing solution for multisignatures or deferred signatures. It was originally created for GameChanger Wallet to improve it's multisignature user experience and boost the multisig dapp and service ecosystem", "main": "dist/cjs/index.js", "module": "dist/esm/index.js", From 60295d092113108a7bf933e59b05b4b3a1e03611 Mon Sep 17 00:00:00 2001 From: zxpectre <15870846+zxpectre@users.noreply.github.com> Date: Thu, 23 Jan 2025 17:12:59 -0300 Subject: [PATCH 3/3] feat: examples updated for Ploming HF. Bump CSL --- examples/nodejs/package-lock.json | 16 ++++++++++------ examples/nodejs/package.json | 4 ++-- examples/nodejs/src/wallet.js | 10 +++++----- examples/react/package-lock.json | 16 ++++++++++------ examples/react/package.json | 6 +++--- examples/react/src/app/services/wallet.ts | 17 +++++++++++------ 6 files changed, 41 insertions(+), 28 deletions(-) diff --git a/examples/nodejs/package-lock.json b/examples/nodejs/package-lock.json index fe79bbe..de84d66 100644 --- a/examples/nodejs/package-lock.json +++ b/examples/nodejs/package-lock.json @@ -9,7 +9,7 @@ "version": "1.0.0", "license": "ISC", "dependencies": { - "@emurgo/cardano-serialization-lib-nodejs": "^11.5.0", + "@emurgo/cardano-serialization-lib-nodejs": "^13.2.1", "@gamechanger-finance/unimatrix": "file:../..", "bip39": "^3.1.0", "dotenv": "^16.4.5", @@ -17,7 +17,8 @@ } }, "../..": { - "version": "1.0.0", + "name": "@gamechanger-finance/unimatrix", + "version": "1.0.3", "hasInstallScript": true, "license": "LICENSE.md", "dependencies": { @@ -27,7 +28,7 @@ "devDependencies": { "@commitlint/cli": "^13.1.0", "@commitlint/config-conventional": "^13.1.0", - "@emurgo/cardano-serialization-lib-nodejs": "^11.5.0", + "@emurgo/cardano-serialization-lib-nodejs": "^13.2.1", "@jest/globals": "^29.7.0", "@types/crypto-js": "^4.2.2", "@types/jest": "^27.5.2", @@ -43,15 +44,18 @@ "prettier": "^2.4.0", "ts-jest": "^27.1.5", "ts-loader": "^9.2.5", + "typedoc": "^0.25.13", + "typedoc-plugin-markdown": "^4.0.3", "typescript": "^4.4.3", "webpack": "^5.52.1", "webpack-cli": "^4.8.0" } }, "node_modules/@emurgo/cardano-serialization-lib-nodejs": { - "version": "11.5.0", - "resolved": "https://registry.npmjs.org/@emurgo/cardano-serialization-lib-nodejs/-/cardano-serialization-lib-nodejs-11.5.0.tgz", - "integrity": "sha512-IlVABlRgo9XaTR1NunwZpWcxnfEv04ba2l1vkUz4S1W7Jt36F4CtffP+jPeqBZGnAe+fnUwo0XjIJC3ZTNToNQ==" + "version": "13.2.1", + "resolved": "https://registry.npmjs.org/@emurgo/cardano-serialization-lib-nodejs/-/cardano-serialization-lib-nodejs-13.2.1.tgz", + "integrity": "sha512-0g2O3YHnoQbkHj5M8FB7ftnljXQ9M3zmKxZnwCbYGr1Pw4FkBA0BRh0+GHPlTxyemcpP2yyuW439I9Ds9drFhA==", + "license": "MIT" }, "node_modules/@gamechanger-finance/unimatrix": { "resolved": "../..", diff --git a/examples/nodejs/package.json b/examples/nodejs/package.json index 003ca9a..8eef17e 100644 --- a/examples/nodejs/package.json +++ b/examples/nodejs/package.json @@ -1,6 +1,6 @@ { "name": "signer-bot", - "version": "1.0.0", + "version": "1.0.1", "description": "A NodeJs Cardano transaction validator and signer bot using Unimatrix Sync. Works with transactions from p2p multisigs, dapps, other bots, or a mix of all. ", "main": "src/index.js", "scripts": { @@ -28,7 +28,7 @@ "author": "zxpectre", "license": "ISC", "dependencies": { - "@emurgo/cardano-serialization-lib-nodejs": "^11.5.0", + "@emurgo/cardano-serialization-lib-nodejs": "^13.2.1", "@gamechanger-finance/unimatrix": "file:../..", "bip39": "^3.1.0", "dotenv": "^16.4.5", diff --git a/examples/nodejs/src/wallet.js b/examples/nodejs/src/wallet.js index 9d3437e..267979a 100644 --- a/examples/nodejs/src/wallet.js +++ b/examples/nodejs/src/wallet.js @@ -66,8 +66,8 @@ const getWalletData = ({ mnemonic, networkTag, dltTag }) => { .to_raw_key() const baseAddressObj = CSL.BaseAddress.new( networkIdByTag(networkTag),//parseInt(networkId), - CSL.StakeCredential.from_keyhash(pubSpendKey.hash()), - CSL.StakeCredential.from_keyhash(pubStakeKey.hash()) + CSL.Credential.from_keyhash(pubSpendKey.hash()), + CSL.Credential.from_keyhash(pubStakeKey.hash()) ); return { address: baseAddressObj.to_address().to_bech32(), @@ -99,8 +99,8 @@ const signTxIfValid = async ({ networkTag, validator, }) => { - const txObj = CSL.Transaction.from_hex(txHex); - const txHashObj = CSL.hash_transaction(txObj.body()); + const txObj = CSL.FixedTransaction.from_hex(txHex); + const txHashObj = txObj.transaction_hash(); const _txHash = txHashObj.to_hex(); if (txHash !== _txHash) throw new Error(`Transaction hash mismatch`); @@ -109,7 +109,7 @@ const signTxIfValid = async ({ if (vkHash !== _vkHash) { throw new Error(`Key hash mismatch`); } - const txJson = JSON.parse(txObj.to_json()); + const txJson=JSON.parse(CSL.Transaction.from_hex(txHex).to_json()); const validation = await validator({ txJson, txHex, diff --git a/examples/react/package-lock.json b/examples/react/package-lock.json index ad1f974..3402445 100644 --- a/examples/react/package-lock.json +++ b/examples/react/package-lock.json @@ -8,7 +8,7 @@ "name": "react", "version": "0.0.0", "dependencies": { - "@emurgo/cardano-serialization-lib-browser": "^11.5.0", + "@emurgo/cardano-serialization-lib-browser": "^13.2.1", "@gamechanger-finance/gc": "^0.1.0", "@gamechanger-finance/unimatrix": "file:../..", "@mdi/font": "^7.4.47", @@ -34,7 +34,8 @@ } }, "../..": { - "version": "1.0.0", + "name": "@gamechanger-finance/unimatrix", + "version": "1.0.3", "hasInstallScript": true, "license": "LICENSE.md", "dependencies": { @@ -44,7 +45,7 @@ "devDependencies": { "@commitlint/cli": "^13.1.0", "@commitlint/config-conventional": "^13.1.0", - "@emurgo/cardano-serialization-lib-nodejs": "^11.5.0", + "@emurgo/cardano-serialization-lib-nodejs": "^13.2.1", "@jest/globals": "^29.7.0", "@types/crypto-js": "^4.2.2", "@types/jest": "^27.5.2", @@ -60,6 +61,8 @@ "prettier": "^2.4.0", "ts-jest": "^27.1.5", "ts-loader": "^9.2.5", + "typedoc": "^0.25.13", + "typedoc-plugin-markdown": "^4.0.3", "typescript": "^4.4.3", "webpack": "^5.52.1", "webpack-cli": "^4.8.0" @@ -425,9 +428,10 @@ } }, "node_modules/@emurgo/cardano-serialization-lib-browser": { - "version": "11.5.0", - "resolved": "https://registry.npmjs.org/@emurgo/cardano-serialization-lib-browser/-/cardano-serialization-lib-browser-11.5.0.tgz", - "integrity": "sha512-qchOJ9NYDUz10tzs5r5QhP9hK0p+ZOlRiBwPdTAxqAYLw/8emYBkQQLaS8T1DF6EkeudyrgS00ym5Trw1fo4iA==" + "version": "13.2.1", + "resolved": "https://registry.npmjs.org/@emurgo/cardano-serialization-lib-browser/-/cardano-serialization-lib-browser-13.2.1.tgz", + "integrity": "sha512-7RfX1gI16Vj2DgCp/ZoXqyLAakWo6+X95ku/rYGbVzuS/1etrlSiJmdbmdm+eYmszMlGQjrtOJQeVLXoj4L/Ag==", + "license": "MIT" }, "node_modules/@esbuild/aix-ppc64": { "version": "0.20.2", diff --git a/examples/react/package.json b/examples/react/package.json index d27623f..2067d7a 100644 --- a/examples/react/package.json +++ b/examples/react/package.json @@ -1,7 +1,7 @@ { - "name": "react", + "name": "react-signer-bot", "private": true, - "version": "0.0.0", + "version": "1.0.1", "type": "module", "scripts": { "dev": "vite", @@ -11,7 +11,7 @@ "link-unimatrix": "npm link @gamechanger-finance/unimatrix" }, "dependencies": { - "@emurgo/cardano-serialization-lib-browser": "^11.5.0", + "@emurgo/cardano-serialization-lib-browser": "^13.2.1", "@gamechanger-finance/gc": "^0.1.0", "@gamechanger-finance/unimatrix": "file:../..", "@mdi/font": "^7.4.47", diff --git a/examples/react/src/app/services/wallet.ts b/examples/react/src/app/services/wallet.ts index 9ce3181..c666f23 100644 --- a/examples/react/src/app/services/wallet.ts +++ b/examples/react/src/app/services/wallet.ts @@ -77,8 +77,8 @@ export const getWalletData=(mnemonic:string,networkTag:string)=>{ .to_raw_key() const baseAddressObj= CardanoWasm().BaseAddress.new( networkIdByTag(networkTag),//parseInt(networkId), - CardanoWasm().StakeCredential.from_keyhash(pubSpendKey.hash()), - CardanoWasm().StakeCredential.from_keyhash(pubStakeKey.hash()) + CardanoWasm().Credential.from_keyhash(pubSpendKey.hash()), + CardanoWasm().Credential.from_keyhash(pubStakeKey.hash()) ); return { address:baseAddressObj.to_address().to_bech32(), @@ -129,13 +129,18 @@ export const signTxIf=async(args:{ }|undefined>=>{ try{ const CSL=CardanoWasm(); - const txObj=CSL.Transaction.from_hex(args.txHex); - const txHashObj=CSL.hash_transaction(txObj.body()); + const txObj=CSL.FixedTransaction.from_hex(args.txHex); + const txHashObj=txObj.transaction_hash(); const txHash=txHashObj.to_hex(); - const txJson=JSON.parse(txObj.to_json()); + const txJson=JSON.parse(CSL.Transaction.from_hex(args.txHex).to_json()); const {doSign:signWithSpend,error:spendError}=await args.conditions.spend({txJson,txHash,vkHash:args?.wallet?.pubSpendKeyHash}); const {doSign:signWithStake,error:stakeError}=await args.conditions.stake({txJson,txHash,vkHash:args?.wallet?.pubStakeKeyHash}); - const res={ + const res:{ + spend:string|undefined, + stake:string|undefined, + spendError:string|undefined, + stakeError:string|undefined, + }={ spend:undefined, stake:undefined, spendError,