From a168021b42c0dc133ba599b214202840e71e5bfe Mon Sep 17 00:00:00 2001 From: Acammm Date: Fri, 5 Nov 2021 11:48:31 +0100 Subject: [PATCH 01/20] What I think should be done - for initialize_pool - for withdraw_pool_usdc --- src/components/Multisig.tsx | 143 ++++++++++++++++++++++++++++++++++++ yarn.lock | 105 +++++++++++++++++++++++++- 2 files changed, 247 insertions(+), 1 deletion(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index b824d63..f5b7ec6 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -762,12 +762,138 @@ function AddTransactionDialog({ multisig={multisig} onClose={onClose} /> + ); } +function InitializeIdoPoolListItem({ + multisig, + onClose, + didAddTransaction, +}: { + multisig: PublicKey; + onClose: Function; + didAddTransaction: (tx: PublicKey) => void; + }) { + const [open, setOpen] = useState(false); + return ( + <> + setOpen((open) => !open)}> + + + + + {open ? : } + + + + + + ); +} + +function InitializeIdoPoolListItemDetails({ + multisig, + onClose, + didAddTransaction, +}: { + multisig: PublicKey; + onClose: Function; + didAddTransaction: (tx: PublicKey) => void; +}) { + const [threshold, setThreshold] = useState(2); // HERE NEED TO RETRIEVE THE VAR from the UI + const { multisigClient } = useWallet(); +// @ts-ignore + const { enqueueSnackbar } = useSnackbar(); + const changeThreshold = async () => { + enqueueSnackbar("Creating IDO pool initialization transaction", { + variant: "info", + }); + const data = initializeIdoPooldData(multisigClient, threshold); // HERE NEED TO SEND THE RIGHT VARS + const [multisigSigner] = await PublicKey.findProgramAddress( + [multisig.toBuffer()], + multisigClient.programId + ); + // HERE NEED TO SEND THE RIGHT ACCOUNTS + const accounts = [ + { + pubkey: multisig, + isWritable: true, + isSigner: false, + }, + { + pubkey: multisigSigner, + isWritable: false, + isSigner: true, + }, + ]; + const transaction = new Account(); + const txSize = 1000; // todo + const tx = await multisigClient.rpc.createTransaction( + multisigClient.programId, + accounts, + data, + { + accounts: { + multisig, + transaction: transaction.publicKey, + proposer: multisigClient.provider.wallet.publicKey, + rent: SYSVAR_RENT_PUBKEY, + }, + signers: [transaction], + instructions: [ + await multisigClient.account.transaction.createInstruction( + transaction, + // @ts-ignore + txSize + ), + ], + } + ); + enqueueSnackbar("Transaction created", { + variant: "success", + action: , + }); + didAddTransaction(transaction.publicKey); + onClose(); + }; + return ( +
+ { + // @ts-ignore + setThreshold(e.target.value); + }} + /> +
+ +
+
+ ); +} + function ChangeThresholdListItem({ multisig, onClose, @@ -1355,6 +1481,23 @@ function changeThresholdData(multisigClient, threshold) { }); } +// @ts-ignore +function initializeIdoPooldData(multisigClient, + num_ido_tokens: number, + nonce: number, + start_ido_ts: number, + end_deposits_ts: number, + end_ido_ts: number +) { + return multisigClient.coder.instruction.encode("initialize_pool", { + num_ido_tokens: new BN(num_ido_tokens), + nonce: new BN(nonce), + start_ido_ts: new BN(start_ido_ts), + end_deposits_ts: new BN(end_deposits_ts), + end_ido_ts: new BN(end_ido_ts), + }); +} + // @ts-ignore function setOwnersData(multisigClient, owners) { return multisigClient.coder.instruction.encode("set_owners", { diff --git a/yarn.lock b/yarn.lock index 1e012b8..a6be1cf 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1191,6 +1191,27 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" +"@ethersproject/bytes@^5.5.0": + version "5.5.0" + resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.5.0.tgz#cb11c526de657e7b45d2e0f0246fb3b9d29a601c" + integrity sha512-ABvc7BHWhZU9PNM/tANm/Qx4ostPGadAuQzWTr3doklZOhDlmcBqclrQe/ZXUIj3K8wC28oYeuRa+A37tX9kog== + dependencies: + "@ethersproject/logger" "^5.5.0" + +"@ethersproject/logger@^5.5.0": + version "5.5.0" + resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.5.0.tgz#0c2caebeff98e10aefa5aef27d7441c7fd18cf5d" + integrity sha512-rIY/6WPm7T8n3qS2vuHTUBPdXHl+rGxWxW5okDfo9J4Z0+gRRZT0msvUdIJkE4/HS29GUMziwGaaKO2bWONBrg== + +"@ethersproject/sha2@^5.5.0": + version "5.5.0" + resolved "https://registry.yarnpkg.com/@ethersproject/sha2/-/sha2-5.5.0.tgz#a40a054c61f98fd9eee99af2c3cc6ff57ec24db7" + integrity sha512-B5UBoglbCiHamRVPLA110J+2uqsifpZaTmid2/7W5rbtYVz6gus6/hSDieIU/6gaKIDcOj12WnOdiymEUHIAOA== + dependencies: + "@ethersproject/bytes" "^5.5.0" + "@ethersproject/logger" "^5.5.0" + hash.js "1.1.7" + "@hapi/address@2.x.x": version "2.1.4" resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5" @@ -1410,6 +1431,17 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" +"@jest/types@^27.2.5": + version "27.2.5" + resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.2.5.tgz#420765c052605e75686982d24b061b4cbba22132" + integrity sha512-nmuM4VuDtCZcY+eTpw+0nvstwReMsjPoj7ZR80/BbixulhLaiX+fbv8oeLW8WZlJMcsGQsTmMKT/iTZu1Uy/lQ== + dependencies: + "@types/istanbul-lib-coverage" "^2.0.0" + "@types/istanbul-reports" "^3.0.0" + "@types/node" "*" + "@types/yargs" "^16.0.0" + chalk "^4.0.0" + "@material-ui/core@^4.11.3": version "4.11.3" resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.11.3.tgz#f22e41775b0bd075e36a7a093d43951bf7f63850" @@ -1707,6 +1739,26 @@ superstruct "^0.14.2" tweetnacl "^1.0.0" +"@solana/web3.js@^1.30.2": + version "1.30.2" + resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.30.2.tgz#e85da75e0825dc64f53eb64a1ff0115b27bec135" + integrity sha512-hznCj+rkfvM5taRP3Z+l5lumB7IQnDrB4l55Wpsg4kDU9Zds8pE5YOH5Z9bbF/pUzZJKQjyBjnY/6kScBm3Ugg== + dependencies: + "@babel/runtime" "^7.12.5" + "@ethersproject/sha2" "^5.5.0" + "@solana/buffer-layout" "^3.0.0" + bn.js "^5.0.0" + borsh "^0.4.0" + bs58 "^4.0.1" + buffer "6.0.1" + cross-fetch "^3.1.4" + jayson "^3.4.4" + js-sha3 "^0.8.0" + rpc-websockets "^7.4.2" + secp256k1 "^4.0.2" + superstruct "^0.14.2" + tweetnacl "^1.0.0" + "@surma/rollup-plugin-off-main-thread@^1.1.1": version "1.4.2" resolved "https://registry.yarnpkg.com/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-1.4.2.tgz#e6786b6af5799f82f7ab3a82e53f6182d2b91a58" @@ -1818,6 +1870,20 @@ "@svgr/plugin-svgo" "^5.5.0" loader-utils "^2.0.0" +"@testing-library/dom@>=8.11.0": + version "8.11.0" + resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.11.0.tgz#3679dfb4db58e0d2b95e4b0929eaf45237b60d94" + integrity sha512-8Ay4UDiMlB5YWy+ZvCeRyFFofs53ebxrWnOFvCoM1HpMAX4cHyuSrCuIM9l2lVuUWUt+Gr3loz/nCwdrnG6ShQ== + dependencies: + "@babel/code-frame" "^7.10.4" + "@babel/runtime" "^7.12.5" + "@types/aria-query" "^4.2.0" + aria-query "^5.0.0" + chalk "^4.1.0" + dom-accessibility-api "^0.5.9" + lz-string "^1.4.4" + pretty-format "^27.0.2" + "@testing-library/dom@^7.28.1": version "7.30.4" resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.30.4.tgz#c6a4a91557e92035fd565246bbbfb8107aa4634d" @@ -2194,6 +2260,13 @@ dependencies: "@types/yargs-parser" "*" +"@types/yargs@^16.0.0": + version "16.0.4" + resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-16.0.4.tgz#26aad98dd2c2a38e421086ea9ad42b9e51642977" + integrity sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw== + dependencies: + "@types/yargs-parser" "*" + "@typescript-eslint/eslint-plugin@^4.5.0": version "4.15.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.15.2.tgz#981b26b4076c62a5a55873fbef3fe98f83360c61" @@ -2598,6 +2671,11 @@ ansi-regex@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== +ansi-regex@^5.0.1: + version "5.0.1" + resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" + integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== + ansi-styles@^3.2.0, ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -2612,6 +2690,11 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: dependencies: color-convert "^2.0.1" +ansi-styles@^5.0.0: + version "5.2.0" + resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" + integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== + any-promise@^1.0.0: version "1.3.0" resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" @@ -2653,6 +2736,11 @@ aria-query@^4.2.2: "@babel/runtime" "^7.10.2" "@babel/runtime-corejs3" "^7.10.2" +aria-query@^5.0.0: + version "5.0.0" + resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-5.0.0.tgz#210c21aaf469613ee8c9a62c7f86525e058db52c" + integrity sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg== + arity-n@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/arity-n/-/arity-n-1.0.4.tgz#d9e76b11733e08569c0847ae7b39b2860b30b745" @@ -4595,6 +4683,11 @@ dom-accessibility-api@^0.5.4: resolved "https://registry.yarnpkg.com/dom-accessibility-api/-/dom-accessibility-api-0.5.4.tgz#b06d059cdd4a4ad9a79275f9d414a5c126241166" integrity sha512-TvrjBckDy2c6v6RLxPv5QXOnU+SmF9nBII5621Ve5fu6Z/BDrENurBEvlC1f44lKEUVqOpK4w9E5Idc5/EgkLQ== +dom-accessibility-api@^0.5.9: + version "0.5.10" + resolved "https://registry.yarnpkg.com/dom-accessibility-api/-/dom-accessibility-api-0.5.10.tgz#caa6d08f60388d0bb4539dd75fe458a9a1d0014c" + integrity sha512-Xu9mD0UjrJisTmv7lmVSDMagQcU9R5hwAbxsaAE/35XPnPLJobbuREfV/rraiSaEj/UOvgrzQs66zyTWTlyd+g== + dom-converter@^0.2: version "0.2.0" resolved "https://registry.yarnpkg.com/dom-converter/-/dom-converter-0.2.0.tgz#6721a9daee2e293682955b6afe416771627bb768" @@ -6006,7 +6099,7 @@ hash-base@^3.0.0: readable-stream "^3.6.0" safe-buffer "^5.2.0" -hash.js@^1.0.0, hash.js@^1.0.3: +hash.js@1.1.7, hash.js@^1.0.0, hash.js@^1.0.3: version "1.1.7" resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== @@ -9699,6 +9792,16 @@ pretty-format@^26.0.0, pretty-format@^26.6.0, pretty-format@^26.6.2: ansi-styles "^4.0.0" react-is "^17.0.1" +pretty-format@^27.0.2: + version "27.3.1" + resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.3.1.tgz#7e9486365ccdd4a502061fa761d3ab9ca1b78df5" + integrity sha512-DR/c+pvFc52nLimLROYjnXPtolawm+uWDxr4FjuLDLUn+ktWnSN851KoHwHzzqq6rfCOjkzN8FLgDrSub6UDuA== + dependencies: + "@jest/types" "^27.2.5" + ansi-regex "^5.0.1" + ansi-styles "^5.0.0" + react-is "^17.0.1" + process-nextick-args@~2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" From f50665fb0898b09b8da7820fbf413eb9b4899f69 Mon Sep 17 00:00:00 2001 From: Acammm Date: Fri, 5 Nov 2021 12:11:55 +0100 Subject: [PATCH 02/20] Deeper --- src/components/Multisig.tsx | 64 ++++++++++++++++++++++++++++++------- 1 file changed, 52 insertions(+), 12 deletions(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index f5b7ec6..58bc38e 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -782,7 +782,7 @@ function InitializeIdoPoolListItem({ onClose: Function; didAddTransaction: (tx: PublicKey) => void; }) { - const [open, setOpen] = useState(false); + const [open, setOpen] = useState(false); return ( <> setOpen((open) => !open)}> @@ -803,6 +803,8 @@ function InitializeIdoPoolListItem({ ); } +const UXDIDOProgramAdress = new PublicKey("UXDJHLPFr8qjLqZs8ejW24zFTq174g1wQHQ4LFhTXxz"); + function InitializeIdoPoolListItemDetails({ multisig, onClose, @@ -811,21 +813,25 @@ function InitializeIdoPoolListItemDetails({ multisig: PublicKey; onClose: Function; didAddTransaction: (tx: PublicKey) => void; -}) { - const [threshold, setThreshold] = useState(2); // HERE NEED TO RETRIEVE THE VAR from the UI + }) { + + const [num_ido_tokens, setNum_ido_tokens] = useState(2); + const [start_ido_ts, setStart_ido_ts] = useState(2); + const [end_deposits_ts, setEnd_deposits_ts] = useState(2); + const [end_ido_ts, setEnd_ido_ts] = useState(2); const { multisigClient } = useWallet(); -// @ts-ignore + // @ts-ignore const { enqueueSnackbar } = useSnackbar(); - const changeThreshold = async () => { + const initializeIdoPool = async () => { enqueueSnackbar("Creating IDO pool initialization transaction", { variant: "info", }); - const data = initializeIdoPooldData(multisigClient, threshold); // HERE NEED TO SEND THE RIGHT VARS + const [,nonce] = await PublicKey.findProgramAddress([UXDIDOProgramAdress.toBuffer()], UXDIDOProgramAdress); + const data = initializeIdoPooldData(multisigClient, num_ido_tokens, nonce, start_ido_ts, end_deposits_ts, end_ido_ts); const [multisigSigner] = await PublicKey.findProgramAddress( [multisig.toBuffer()], multisigClient.programId ); - // HERE NEED TO SEND THE RIGHT ACCOUNTS const accounts = [ { pubkey: multisig, @@ -837,6 +843,7 @@ function InitializeIdoPoolListItemDetails({ isWritable: false, isSigner: true, }, + // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. ]; const transaction = new Account(); const txSize = 1000; // todo @@ -879,16 +886,49 @@ function InitializeIdoPoolListItemDetails({ { // @ts-ignore - setThreshold(e.target.value); + setNum_ido_tokens(e.target.value); + }} + /> + { + // @ts-ignore + setStart_ido_ts(e.target.value); + }} + /> + { + // @ts-ignore + setEnd_deposits_ts(e.target.value); + }} + /> + { + // @ts-ignore + setEnd_ido_ts(e.target.value); }} />
- +
); @@ -932,7 +972,7 @@ function ChangeThresholdListItemDetails({ multisig: PublicKey; onClose: Function; didAddTransaction: (tx: PublicKey) => void; -}) { + }) { const [threshold, setThreshold] = useState(2); const { multisigClient } = useWallet(); // @ts-ignore From b1ee7197fa016183dfcce54d2cbcc4de6d547c7f Mon Sep 17 00:00:00 2001 From: Acammm Date: Fri, 5 Nov 2021 12:13:00 +0100 Subject: [PATCH 03/20] more details --- src/components/Multisig.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index 58bc38e..2d7c450 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -843,10 +843,11 @@ function InitializeIdoPoolListItemDetails({ isWritable: false, isSigner: true, }, - // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. + // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. + // Accounts expected can be found here https://github.com/UXDProtocol/uxd_ido/blob/main/programs/uxd_ido/src/lib.rs#L281 ]; const transaction = new Account(); - const txSize = 1000; // todo + const txSize = 1000; // todo const tx = await multisigClient.rpc.createTransaction( multisigClient.programId, accounts, From 8d1b00d2ea8ffefd27ecaef1470395d0495f750a Mon Sep 17 00:00:00 2001 From: Acammm Date: Fri, 5 Nov 2021 12:20:08 +0100 Subject: [PATCH 04/20] More details --- src/components/Multisig.tsx | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index 2d7c450..80616d1 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -845,6 +845,33 @@ function InitializeIdoPoolListItemDetails({ }, // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. // Accounts expected can be found here https://github.com/UXDProtocol/uxd_ido/blob/main/programs/uxd_ido/src/lib.rs#L281 + + // pool_account -- can be created arbitrarily - then will need to be referenced in the other operations and used on the front end (THE POINTER TO OUR IDO) + + // pool_signer -- this is the multisig PDA : 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT + + // redeemable_mint -- Wrapped sollet USDC? which one do we use https://solscan.io/token/BXXkv6z8ykpG1yuvUDPgh732wzVHB69RnB9YgSYh3itW + + // uxp_mint -- This is UXP UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M token () https://solscan.io/token/UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M () + + // pool_uxp -- + + // pool_usdc -- + + // distribution_authority -- should be the multisig PDA - might have an issue with the program cause it's also a payer + // 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT + // NGMI if we discover issues last minute, this need to be done asap for our mental wellbeing, sorry to be lame but it's super important + + // creator_uxp -- Not sure what is this what was used before? + + // token_program + + // system_program + + // rent + + // clock + ]; const transaction = new Account(); const txSize = 1000; // todo From 0ba413d88f64e1c6b965f9c6f7ddbd625ea9042a Mon Sep 17 00:00:00 2001 From: Acammm Date: Fri, 5 Nov 2021 12:22:34 +0100 Subject: [PATCH 05/20] more details --- src/components/Multisig.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index 80616d1..0fe4671 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -803,6 +803,8 @@ function InitializeIdoPoolListItem({ ); } +// UXD MULTISIG instance AFBx8bHKmfqVxaHxgL8hLmrxJip8Dq8fZckngpQzVVG3 +// it's PDA 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT (The one owning shits) const UXDIDOProgramAdress = new PublicKey("UXDJHLPFr8qjLqZs8ejW24zFTq174g1wQHQ4LFhTXxz"); function InitializeIdoPoolListItemDetails({ From 03ddd59a08272971d870fca6483216b9fe861a69 Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sat, 6 Nov 2021 03:59:23 +0900 Subject: [PATCH 06/20] complete initialize IDO and withdraw USDC IDO transactions --- src/components/Multisig.tsx | 356 +++++++++++++++++++++++++++++++----- src/utils/uxd_helper.ts | 86 +++++++++ 2 files changed, 397 insertions(+), 45 deletions(-) create mode 100644 src/utils/uxd_helper.ts diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index 0fe4671..e2e14f0 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -44,6 +44,7 @@ import CheckCircleIcon from "@material-ui/icons/CheckCircle"; import BN from "bn.js"; import { Account, + Keypair, PublicKey, SYSVAR_RENT_PUBKEY, SYSVAR_CLOCK_PUBKEY, @@ -53,6 +54,8 @@ import { useWallet } from "./WalletProvider"; import { ViewTransactionOnExplorerButton } from "./Notification"; import * as idl from "../utils/idl"; import { networks } from "../store/reducer"; +import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; +import { createMint, createTokenAccount } from "../utils/uxd_helper"; export default function Multisig({ multisig }: { multisig?: PublicKey }) { return ( @@ -257,7 +260,7 @@ export function NewMultisigDialog({ const multisig = new Account(); // Disc. + threshold + nonce. const baseSize = 8 + 8 + 1 + 4; - // Add enough for 2 more participants, in case the user changes one's + // Add enough for 2 more participants, in case the user changes one"s /// mind later. const fudge = 64; // Can only grow the participant set by 2x the initialized value. @@ -767,12 +770,47 @@ function AddTransactionDialog({ multisig={multisig} onClose={onClose} /> + ); } +function WithdrawUSDCPoolListItem({ + multisig, + onClose, + didAddTransaction, +}: { + multisig: PublicKey; + onClose: Function; + didAddTransaction: (tx: PublicKey) => void; +}) { + const [open, setOpen] = useState(false); + return ( + <> + setOpen((open) => !open)}> + + + + + {open ? : } + + + + + + ); +} + function InitializeIdoPoolListItem({ multisig, onClose, @@ -804,8 +842,164 @@ function InitializeIdoPoolListItem({ } // UXD MULTISIG instance AFBx8bHKmfqVxaHxgL8hLmrxJip8Dq8fZckngpQzVVG3 -// it's PDA 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT (The one owning shits) +// its PDA 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT (The one owning shits) const UXDIDOProgramAdress = new PublicKey("UXDJHLPFr8qjLqZs8ejW24zFTq174g1wQHQ4LFhTXxz"); +const multisigPDA = new PublicKey("35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT"); //? Can we actually get that from the multisigClient? +const uxpMint = new PublicKey("UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M"); +const usdcMint = new PublicKey("2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9"); //* That"s the mainnet one +const uxpMultisigTokenAccount = new PublicKey("GJgkVjjsYZeY2RLKcd7346A2dreykurTxkeNw6ysVQkc"); //! We should be able to get it from chain + +function WithdrawUSDCPoolListItemDetails({ + multisig, + onClose, + didAddTransaction, +}: { + multisig: PublicKey; + onClose: Function; + didAddTransaction: (tx: PublicKey) => void; +}) { + const [poolAccountAddr, setPoolAccountAddr] = useState(""); + const [poolUsdcAddr, setPoolUsdcAddr] = useState(""); + const [multisigUsdcAddr, setMultisigUsdcAddr] = useState(""); + const { multisigClient } = useWallet(); + // @ts-ignore + const { enqueueSnackbar } = useSnackbar(); + const withdrawIdoPool = async () => { + enqueueSnackbar("Creating USDC pool withdraw transaction", { + variant: "info", + }); + + const data = withdrawIdoUsdcPoolData(multisigClient); + + const accounts = [ + // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. + // Accounts expected can be found here https://github.com/UXDProtocol/uxd_ido/blob/main/programs/uxd_ido/src/lib.rs#L281 + + // pool_account -- can be created arbitrarily - then will need to be referenced in the other operations and used on the front end (THE POINTER TO OUR IDO) + { + pubkey: new PublicKey(poolAccountAddr), + isWritable: true, + isSigner: true, + }, + // pool_signer -- this is the multisig PDA : 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT + //? While testing we used to use a derivation from the uxp mint for creating this account + { + pubkey: multisigPDA, + isWritable: false, + isSigner: true, + }, + + // pool_usdc -- + { + pubkey: new PublicKey(poolUsdcAddr), + isWritable: false, + isSigner: false, + }, + // distribution_authority -- should be the multisig PDA - might have an issue with the program cause it"s also a payer + // 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT + // NGMI if we discover issues last minute, this need to be done asap for our mental wellbeing, sorry to be lame but it"s super important + { + pubkey: multisigPDA, + isWritable: true, + isSigner: true, + }, + // creator_usdc -- is actually the token account that will receive the usdc + { + pubkey: new PublicKey(multisigUsdcAddr), + isWritable: true, + isSigner: false, + }, + // token_program + { + pubkey: TOKEN_PROGRAM_ID, + isWritable: false, + isSigner: false, + }, + + // clock + { + pubkey: anchor.web3.SYSVAR_CLOCK_PUBKEY, + isWritable: false, + isSigner: false, + }, + ]; + const transaction = new Keypair(); + const txSize = 1000; // todo + const tx = await multisigClient.rpc.createTransaction( + multisigClient.programId, + accounts, + data, + { + accounts: { + multisig, + transaction: transaction.publicKey, + proposer: multisigClient.provider.wallet.publicKey, + rent: SYSVAR_RENT_PUBKEY, + }, + signers: [transaction], + instructions: [ + await multisigClient.account.transaction.createInstruction( + transaction, + // @ts-ignore + txSize + ), + ], + } + ); + enqueueSnackbar("Transaction created", { + variant: "success", + action: , + }); + didAddTransaction(transaction.publicKey); + onClose(); + }; + return ( +
+ { + // @ts-ignore + setPoolAccountAddr(e.target.value); + }} + /> + { + // @ts-ignore + setPoolUsdcAddr(e.target.value); + }} + /> + { + // @ts-ignore + setMultisigUsdcAddr(e.target.value); + }} + /> +
+ +
+
+ ); +} function InitializeIdoPoolListItemDetails({ multisig, @@ -834,48 +1028,114 @@ function InitializeIdoPoolListItemDetails({ [multisig.toBuffer()], multisigClient.programId ); - const accounts = [ - { - pubkey: multisig, - isWritable: true, - isSigner: false, - }, - { - pubkey: multisigSigner, - isWritable: false, - isSigner: true, - }, - // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. - // Accounts expected can be found here https://github.com/UXDProtocol/uxd_ido/blob/main/programs/uxd_ido/src/lib.rs#L281 - - // pool_account -- can be created arbitrarily - then will need to be referenced in the other operations and used on the front end (THE POINTER TO OUR IDO) - - // pool_signer -- this is the multisig PDA : 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT - - // redeemable_mint -- Wrapped sollet USDC? which one do we use https://solscan.io/token/BXXkv6z8ykpG1yuvUDPgh732wzVHB69RnB9YgSYh3itW - - // uxp_mint -- This is UXP UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M token () https://solscan.io/token/UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M () - // pool_uxp -- + const poolAccount = Keypair.generate(); + console.log("poolAccount: ", poolAccount.publicKey.toBase58().toString()); + const redeemableMint = await createMint(multisigClient.provider, multisigSigner); + console.log("redeemableMint: ", redeemableMint.toBase58()); + const poolUxp = await createTokenAccount(multisigClient.provider, uxpMint, multisigSigner); + console.log("poolUxp: ", poolUxp.toBase58()); + const poolUsdc = await createTokenAccount( + multisigClient.provider, + usdcMint, + multisigSigner + ); + console.log("poolUsdc: ", poolUsdc.toBase58()); - // pool_usdc -- - - // distribution_authority -- should be the multisig PDA - might have an issue with the program cause it's also a payer - // 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT - // NGMI if we discover issues last minute, this need to be done asap for our mental wellbeing, sorry to be lame but it's super important - - // creator_uxp -- Not sure what is this what was used before? - - // token_program - - // system_program - - // rent - - // clock - - ]; - const transaction = new Account(); + const accounts = [ + //? Do we need these two for some multisig stuff? + // { + // pubkey: multisig, + // isWritable: true, + // isSigner: false, + // }, + // { + // pubkey: multisigSigner, + // isWritable: false, + // isSigner: true, + // }, + // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. + // Accounts expected can be found here https://github.com/UXDProtocol/uxd_ido/blob/main/programs/uxd_ido/src/lib.rs#L281 + + // pool_account -- can be created arbitrarily - then will need to be referenced in the other operations and used on the front end (THE POINTER TO OUR IDO) + { + pubkey: poolAccount.publicKey, + isWritable: true, + isSigner: true, + }, + // pool_signer -- this is the multisig PDA : 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT + //? While testing we used to use a derivation from the uxp mint for creating this account + { + pubkey: multisigPDA, + isWritable: false, + isSigner: true, + }, + // redeemable_mint -- Wrapped sollet USDC? which one do we use https://solscan.io/token/BXXkv6z8ykpG1yuvUDPgh732wzVHB69RnB9YgSYh3itW + // apparently we do not have to give a shit, jsute create a random mint account + { + pubkey: redeemableMint, + isWritable: false, + isSigner: false, + }, + // uxp_mint -- This is UXP UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M token () https://solscan.io/token/UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M () + { + pubkey: new PublicKey("UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M"), + isWritable: false, + isSigner: false, + }, + // pool_uxp -- + { + pubkey: poolUxp, + isWritable: false, + isSigner: false, + }, + // pool_usdc -- + { + pubkey: poolUsdc, + isWritable: false, + isSigner: false, + }, + // distribution_authority -- should be the multisig PDA - might have an issue with the program cause it"s also a payer + // 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT + // NGMI if we discover issues last minute, this need to be done asap for our mental wellbeing, sorry to be lame but it"s super important + { + pubkey: multisigPDA, + isWritable: true, + isSigner: true, + }, + // creator_uxp -- Not sure what is this what was used before + //* It is the token account that holds the UXP that will be transfered to the uxpPool at initialization + { + pubkey: uxpMultisigTokenAccount, + isWritable: true, + isSigner: false, + }, + // token_program + { + pubkey: TOKEN_PROGRAM_ID, + isWritable: false, + isSigner: false, + }, + // system_program + { + pubkey: anchor.web3.SystemProgram.programId, + isWritable: false, + isSigner: false, + }, + // rent + { + pubkey: anchor.web3.SYSVAR_RENT_PUBKEY, + isWritable: false, + isSigner: false, + }, + // clock + { + pubkey: anchor.web3.SYSVAR_CLOCK_PUBKEY, + isWritable: false, + isSigner: false, + }, + ]; + const transaction = new Keypair(); const txSize = 1000; // todo const tx = await multisigClient.rpc.createTransaction( multisigClient.programId, @@ -927,7 +1187,7 @@ function InitializeIdoPoolListItemDetails({ { @@ -938,7 +1198,7 @@ function InitializeIdoPoolListItemDetails({ { @@ -949,7 +1209,7 @@ function InitializeIdoPoolListItemDetails({ { @@ -1568,6 +1828,12 @@ function initializeIdoPooldData(multisigClient, }); } + +// @ts-ignore +function withdrawIdoUsdcPoolData(multisigClient: any) { + return multisigClient.coder.instruction.encode("withdraw_pool_usdc"); +} + // @ts-ignore function setOwnersData(multisigClient, owners) { return multisigClient.coder.instruction.encode("set_owners", { diff --git a/src/utils/uxd_helper.ts b/src/utils/uxd_helper.ts new file mode 100644 index 0000000..c5827dd --- /dev/null +++ b/src/utils/uxd_helper.ts @@ -0,0 +1,86 @@ +// TODO: use the `@solana/spl-token` package instead of utils here. +import * as anchor from '@project-serum/anchor'; +import { TokenInstructions } from '@project-serum/serum'; + +// TODO: remove this constant once @project-serum/serum uses the same version +// of @solana/web3.js as anchor (or switch packages). +const TOKEN_PROGRAM_ID = new anchor.web3.PublicKey(TokenInstructions.TOKEN_PROGRAM_ID.toString()); + + + +export async function createMint(provider: anchor.Provider, authority: anchor.web3.PublicKey) { + if (authority === undefined) { + authority = provider.wallet.publicKey; + } + const mint = anchor.web3.Keypair.generate(); + const instructions = await createMintInstructions(provider, authority, mint.publicKey); + + const tx = new anchor.web3.Transaction(); + tx.add(...instructions); + + await provider.send(tx, [mint]); + + return mint.publicKey; +} + +async function createMintInstructions( + provider: anchor.Provider, + authority: anchor.web3.PublicKey, + mint: anchor.web3.PublicKey +) { + let instructions = [ + anchor.web3.SystemProgram.createAccount({ + fromPubkey: provider.wallet.publicKey, + newAccountPubkey: mint, + space: 82, + lamports: await provider.connection.getMinimumBalanceForRentExemption(82), + programId: TOKEN_PROGRAM_ID, + }), + TokenInstructions.initializeMint({ + mint, + decimals: 6, + mintAuthority: authority, + }), + ]; + return instructions; +} + +export async function createTokenAccount( + provider: anchor.Provider, + mint: anchor.web3.PublicKey, + owner: anchor.web3.PublicKey +) { + const vault = anchor.web3.Keypair.generate(); + const tx = new anchor.web3.Transaction(); + tx.add(...(await createTokenAccountInstrs(provider, vault.publicKey, mint, owner))); + await provider.send(tx, [vault]); + return vault.publicKey; +} + +async function createTokenAccountInstrs( + provider: anchor.Provider, + newAccountPubkey: anchor.web3.PublicKey, + mint: anchor.web3.PublicKey, + owner: anchor.web3.PublicKey, + lamports?: number +) { + if (lamports === undefined) { + lamports = await provider.connection.getMinimumBalanceForRentExemption(165); + } + return [ + anchor.web3.SystemProgram.createAccount({ + fromPubkey: provider.wallet.publicKey, + newAccountPubkey, + space: 165, + lamports, + programId: TOKEN_PROGRAM_ID, + }), + TokenInstructions.initializeAccount({ + account: newAccountPubkey, + mint, + owner, + }), + ]; +} + + From 2a7f27d9670366654a23bb40c762ae5f90294a7e Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 00:10:40 +0900 Subject: [PATCH 07/20] add poolSigner, accounts generated on the fly --- src/components/Multisig.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index e2e14f0..ef0ca0b 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -1042,6 +1042,13 @@ function InitializeIdoPoolListItemDetails({ ); console.log("poolUsdc: ", poolUsdc.toBase58()); + // We use the uxp mint address as the seed, could use something else though. + const [_poolSigner] = await anchor.web3.PublicKey.findProgramAddress( + [uxpMint.toBuffer()], + UXDIDOProgramAdress + ); + const poolSigner = _poolSigner; + const accounts = [ //? Do we need these two for some multisig stuff? // { @@ -1066,7 +1073,7 @@ function InitializeIdoPoolListItemDetails({ // pool_signer -- this is the multisig PDA : 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT //? While testing we used to use a derivation from the uxp mint for creating this account { - pubkey: multisigPDA, + pubkey: poolSigner, isWritable: false, isSigner: true, }, From 35bef4dfb589807b795405b88ed596e55db2b88a Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 01:09:41 +0900 Subject: [PATCH 08/20] createMint and token are instructions injected in main call --- src/components/Multisig.tsx | 70 ++++++++++++++++++++----------------- src/utils/uxd_helper.ts | 36 ++++++++++++++----- 2 files changed, 64 insertions(+), 42 deletions(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index ef0ca0b..5e46c30 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -55,7 +55,7 @@ import { ViewTransactionOnExplorerButton } from "./Notification"; import * as idl from "../utils/idl"; import { networks } from "../store/reducer"; import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; -import { createMint, createTokenAccount } from "../utils/uxd_helper"; +import { createMint, createTokenAccount, findAssociatedTokenAddress } from "../utils/uxd_helper"; export default function Multisig({ multisig }: { multisig?: PublicKey }) { return ( @@ -860,11 +860,18 @@ function WithdrawUSDCPoolListItemDetails({ }) { const [poolAccountAddr, setPoolAccountAddr] = useState(""); const [poolUsdcAddr, setPoolUsdcAddr] = useState(""); - const [multisigUsdcAddr, setMultisigUsdcAddr] = useState(""); const { multisigClient } = useWallet(); - // @ts-ignore + const { enqueueSnackbar } = useSnackbar(); const withdrawIdoPool = async () => { + const itxs: anchor.web3.TransactionInstruction[] = []; + let multisigUsdc = findAssociatedTokenAddress(multisigPDA, usdcMint) + if (!multisigUsdc) { + const { account: multisigUsdcAcc, instructions: createmultisigUsdcItxs} = await createTokenAccount(multisigClient.provider, usdcMint, multisigPDA); + multisigUsdc= multisigUsdcAcc.publicKey + itxs.push(...createmultisigUsdcItxs); + } + // @ts-ignore enqueueSnackbar("Creating USDC pool withdraw transaction", { variant: "info", }); @@ -905,7 +912,7 @@ function WithdrawUSDCPoolListItemDetails({ }, // creator_usdc -- is actually the token account that will receive the usdc { - pubkey: new PublicKey(multisigUsdcAddr), + pubkey: multisigUsdc, isWritable: true, isSigner: false, }, @@ -925,6 +932,11 @@ function WithdrawUSDCPoolListItemDetails({ ]; const transaction = new Keypair(); const txSize = 1000; // todo + itxs.push((await multisigClient.account.transaction.createInstruction( + transaction, + // @ts-ignore + txSize + ))); const tx = await multisigClient.rpc.createTransaction( multisigClient.programId, accounts, @@ -938,11 +950,8 @@ function WithdrawUSDCPoolListItemDetails({ }, signers: [transaction], instructions: [ - await multisigClient.account.transaction.createInstruction( - transaction, - // @ts-ignore - txSize - ), + + ...itxs ], } ); @@ -983,17 +992,6 @@ function WithdrawUSDCPoolListItemDetails({ setPoolUsdcAddr(e.target.value); }} /> - { - // @ts-ignore - setMultisigUsdcAddr(e.target.value); - }} - />
@@ -1029,18 +1027,21 @@ function InitializeIdoPoolListItemDetails({ multisigClient.programId ); + const itxs = []; const poolAccount = Keypair.generate(); - console.log("poolAccount: ", poolAccount.publicKey.toBase58().toString()); - const redeemableMint = await createMint(multisigClient.provider, multisigSigner); - console.log("redeemableMint: ", redeemableMint.toBase58()); - const poolUxp = await createTokenAccount(multisigClient.provider, uxpMint, multisigSigner); - console.log("poolUxp: ", poolUxp.toBase58()); - const poolUsdc = await createTokenAccount( + console.log("poolAccount: ", poolAccount.publicKey.toBase58()) + console.log("redeemableMint: "); + const {mint: redeemableMint, instructions: redeemableMintItxs} = await createMint(multisigClient.provider, multisigSigner); + console.log("poolUxp: "); + const {account: poolUxp, instructions: poolUxpItxs} = await createTokenAccount(multisigClient.provider, uxpMint, multisigSigner); + console.log("poolUsdc: "); + + const {account: poolUsdc, instructions: poolUsdcItxs} = await createTokenAccount( multisigClient.provider, usdcMint, multisigSigner ); - console.log("poolUsdc: ", poolUsdc.toBase58()); + itxs.push(...redeemableMintItxs, ...poolUxpItxs, ...poolUsdcItxs); // We use the uxp mint address as the seed, could use something else though. const [_poolSigner] = await anchor.web3.PublicKey.findProgramAddress( @@ -1048,7 +1049,7 @@ function InitializeIdoPoolListItemDetails({ UXDIDOProgramAdress ); const poolSigner = _poolSigner; - + const accounts = [ //? Do we need these two for some multisig stuff? // { @@ -1144,6 +1145,12 @@ function InitializeIdoPoolListItemDetails({ ]; const transaction = new Keypair(); const txSize = 1000; // todo + + itxs.push((await multisigClient.account.transaction.createInstruction( + transaction, + // @ts-ignore + txSize + ))); const tx = await multisigClient.rpc.createTransaction( multisigClient.programId, accounts, @@ -1157,11 +1164,8 @@ function InitializeIdoPoolListItemDetails({ }, signers: [transaction], instructions: [ - await multisigClient.account.transaction.createInstruction( - transaction, - // @ts-ignore - txSize - ), + itxs + ], } ); diff --git a/src/utils/uxd_helper.ts b/src/utils/uxd_helper.ts index c5827dd..e52a3ba 100644 --- a/src/utils/uxd_helper.ts +++ b/src/utils/uxd_helper.ts @@ -6,6 +6,8 @@ import { TokenInstructions } from '@project-serum/serum'; // of @solana/web3.js as anchor (or switch packages). const TOKEN_PROGRAM_ID = new anchor.web3.PublicKey(TokenInstructions.TOKEN_PROGRAM_ID.toString()); +const ASSOC_TOKEN_PROGRAM_ID = new anchor.web3.PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'); + export async function createMint(provider: anchor.Provider, authority: anchor.web3.PublicKey) { @@ -13,14 +15,15 @@ export async function createMint(provider: anchor.Provider, authority: anchor.we authority = provider.wallet.publicKey; } const mint = anchor.web3.Keypair.generate(); + console.log(mint.publicKey.toBase58()) const instructions = await createMintInstructions(provider, authority, mint.publicKey); + return { mint, instructions}; + // const tx = new anchor.web3.Transaction(); + // tx.add(...instructions); - const tx = new anchor.web3.Transaction(); - tx.add(...instructions); - - await provider.send(tx, [mint]); + // await provider.send(tx, [mint]); - return mint.publicKey; + // return mint.publicKey; } async function createMintInstructions( @@ -51,10 +54,12 @@ export async function createTokenAccount( owner: anchor.web3.PublicKey ) { const vault = anchor.web3.Keypair.generate(); - const tx = new anchor.web3.Transaction(); - tx.add(...(await createTokenAccountInstrs(provider, vault.publicKey, mint, owner))); - await provider.send(tx, [vault]); - return vault.publicKey; + console.log(vault.publicKey.toBase58()) + //const tx = new anchor.web3.Transaction(); + const instructions = await createTokenAccountInstrs(provider, vault.publicKey, mint, owner); + return { account: vault, instructions} + // await provider.send(tx, [vault]); + // return vault.publicKey; } async function createTokenAccountInstrs( @@ -84,3 +89,16 @@ async function createTokenAccountInstrs( } +// derives the canonical token account address for a given wallet and mint +export function findAssociatedTokenAddress(walletKey: anchor.web3.PublicKey, mintKey: anchor.web3.PublicKey,) { + if (!walletKey || !mintKey) return; + return findAddr( + [walletKey.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mintKey.toBuffer()], + ASSOC_TOKEN_PROGRAM_ID + ); +} + +// simple shorthand +function findAddr(seeds: (Buffer | Uint8Array)[], programId: anchor.web3.PublicKey) { + return anchor.utils.publicKey.findProgramAddressSync(seeds, programId)[0]; +} \ No newline at end of file From 13e77b62825c452dd3d6f23223facd24d1d52d95 Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 01:14:59 +0900 Subject: [PATCH 09/20] use poolSigner from uxpmint derivation in withdraw usdc --- src/components/Multisig.tsx | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index 5e46c30..5d9cf12 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -871,6 +871,12 @@ function WithdrawUSDCPoolListItemDetails({ multisigUsdc= multisigUsdcAcc.publicKey itxs.push(...createmultisigUsdcItxs); } + // We use the uxp mint address as the seed, could use something else though. + const [_poolSigner] = await anchor.web3.PublicKey.findProgramAddress( + [uxpMint.toBuffer()], + UXDIDOProgramAdress + ); + const poolSigner = _poolSigner; // @ts-ignore enqueueSnackbar("Creating USDC pool withdraw transaction", { variant: "info", @@ -891,7 +897,7 @@ function WithdrawUSDCPoolListItemDetails({ // pool_signer -- this is the multisig PDA : 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT //? While testing we used to use a derivation from the uxp mint for creating this account { - pubkey: multisigPDA, + pubkey: poolSigner, isWritable: false, isSigner: true, }, From 82ccee95b1d50be91cc196847caf1eff25f5ee4f Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 01:24:43 +0900 Subject: [PATCH 10/20] use Marinade instead of uxp for testing --- src/components/Multisig.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index 5d9cf12..638322f 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -845,7 +845,7 @@ function InitializeIdoPoolListItem({ // its PDA 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT (The one owning shits) const UXDIDOProgramAdress = new PublicKey("UXDJHLPFr8qjLqZs8ejW24zFTq174g1wQHQ4LFhTXxz"); const multisigPDA = new PublicKey("35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT"); //? Can we actually get that from the multisigClient? -const uxpMint = new PublicKey("UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M"); +const uxpMint = new PublicKey('MNDEFzGvMt87ueuHvVU9VcTqsAP5b3fTGPsHuuPA5ey');//new PublicKey("UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M"); const usdcMint = new PublicKey("2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9"); //* That"s the mainnet one const uxpMultisigTokenAccount = new PublicKey("GJgkVjjsYZeY2RLKcd7346A2dreykurTxkeNw6ysVQkc"); //! We should be able to get it from chain From 51b3dde0255be8d7f13529310db650445ba4de21 Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 02:12:41 +0900 Subject: [PATCH 11/20] encode data using uxd anchor program --- src/components/Multisig.tsx | 19 +++++++++---------- src/components/WalletProvider.tsx | 17 ++++++++++++++--- 2 files changed, 23 insertions(+), 13 deletions(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index 638322f..ef415e4 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -56,7 +56,6 @@ import * as idl from "../utils/idl"; import { networks } from "../store/reducer"; import { TOKEN_PROGRAM_ID } from "@solana/spl-token"; import { createMint, createTokenAccount, findAssociatedTokenAddress } from "../utils/uxd_helper"; - export default function Multisig({ multisig }: { multisig?: PublicKey }) { return (
@@ -99,7 +98,7 @@ function NewMultisigButton() { } export function MultisigInstance({ multisig }: { multisig: PublicKey }) { - const { multisigClient } = useWallet(); + const { multisigClient, uxdClient } = useWallet(); const [multisigAccount, setMultisigAccount] = useState(undefined); const [transactions, setTransactions] = useState(null); const [showSignerDialog, setShowSignerDialog] = useState(false); @@ -860,7 +859,7 @@ function WithdrawUSDCPoolListItemDetails({ }) { const [poolAccountAddr, setPoolAccountAddr] = useState(""); const [poolUsdcAddr, setPoolUsdcAddr] = useState(""); - const { multisigClient } = useWallet(); + const { multisigClient, uxdClient } = useWallet(); const { enqueueSnackbar } = useSnackbar(); const withdrawIdoPool = async () => { @@ -882,7 +881,7 @@ function WithdrawUSDCPoolListItemDetails({ variant: "info", }); - const data = withdrawIdoUsdcPoolData(multisigClient); + const data = withdrawIdoUsdcPoolData(uxdClient); const accounts = [ // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. @@ -1019,7 +1018,7 @@ function InitializeIdoPoolListItemDetails({ const [start_ido_ts, setStart_ido_ts] = useState(2); const [end_deposits_ts, setEnd_deposits_ts] = useState(2); const [end_ido_ts, setEnd_ido_ts] = useState(2); - const { multisigClient } = useWallet(); + const { multisigClient, uxdClient } = useWallet(); // @ts-ignore const { enqueueSnackbar } = useSnackbar(); const initializeIdoPool = async () => { @@ -1027,7 +1026,7 @@ function InitializeIdoPoolListItemDetails({ variant: "info", }); const [,nonce] = await PublicKey.findProgramAddress([UXDIDOProgramAdress.toBuffer()], UXDIDOProgramAdress); - const data = initializeIdoPooldData(multisigClient, num_ido_tokens, nonce, start_ido_ts, end_deposits_ts, end_ido_ts); + const data = initializeIdoPoolData(uxdClient, num_ido_tokens, nonce, start_ido_ts, end_deposits_ts, end_ido_ts); const [multisigSigner] = await PublicKey.findProgramAddress( [multisig.toBuffer()], multisigClient.programId @@ -1829,14 +1828,14 @@ function changeThresholdData(multisigClient, threshold) { } // @ts-ignore -function initializeIdoPooldData(multisigClient, +function initializeIdoPoolData(uxdClient, num_ido_tokens: number, nonce: number, start_ido_ts: number, end_deposits_ts: number, end_ido_ts: number ) { - return multisigClient.coder.instruction.encode("initialize_pool", { + return uxdClient.coder.instruction.encode("initialize_pool", { num_ido_tokens: new BN(num_ido_tokens), nonce: new BN(nonce), start_ido_ts: new BN(start_ido_ts), @@ -1847,8 +1846,8 @@ function initializeIdoPooldData(multisigClient, // @ts-ignore -function withdrawIdoUsdcPoolData(multisigClient: any) { - return multisigClient.coder.instruction.encode("withdraw_pool_usdc"); +function withdrawIdoUsdcPoolData(uxdClient: any) { + return uxdClient.coder.instruction.encode("withdraw_pool_usdc"); } // @ts-ignore diff --git a/src/components/WalletProvider.tsx b/src/components/WalletProvider.tsx index 3b07d0c..a9190cb 100644 --- a/src/components/WalletProvider.tsx +++ b/src/components/WalletProvider.tsx @@ -9,9 +9,10 @@ import { useSelector } from "react-redux"; import { Connection, ConfirmOptions } from "@solana/web3.js"; // @ts-ignore import Wallet from "@project-serum/sol-wallet-adapter"; -import { Program, Provider } from "@project-serum/anchor"; +import { Program, Provider, web3 } from "@project-serum/anchor"; import { State as StoreState } from "../store/reducer"; import MultisigIdl from "../idl"; +import uxdIdl from "../idl/controllerUXD"; export function useWallet(): WalletContextValues { const w = useContext(WalletContext); @@ -27,6 +28,7 @@ const WalletContext = React.createContext(null); type WalletContextValues = { wallet: Wallet; multisigClient: Program; + uxdClient: Program }; export default function WalletProvider( @@ -39,7 +41,7 @@ export default function WalletProvider( }; }); - const { wallet, multisigClient } = useMemo(() => { + const { wallet, multisigClient, uxdClient } = useMemo(() => { const opts: ConfirmOptions = { preflightCommitment: "recent", commitment: "recent", @@ -54,14 +56,23 @@ export default function WalletProvider( provider ); + const UXDIDOProgramAdress = new web3.PublicKey("UXDJHLPFr8qjLqZs8ejW24zFTq174g1wQHQ4LFhTXxz"); + + const uxdClient = new Program( + uxdIdl, + UXDIDOProgramAdress, + provider + ) + return { wallet, multisigClient, + uxdClient }; }, [walletProvider, network]); return ( - + {props.children} ); From 31e14ab675febcf2469214a912fd46e72192a7d5 Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 02:13:13 +0900 Subject: [PATCH 12/20] add UXD ido idl --- src/idl/controllerUXD.ts | 441 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 441 insertions(+) create mode 100644 src/idl/controllerUXD.ts diff --git a/src/idl/controllerUXD.ts b/src/idl/controllerUXD.ts new file mode 100644 index 0000000..0884a81 --- /dev/null +++ b/src/idl/controllerUXD.ts @@ -0,0 +1,441 @@ +import { Idl } from "@project-serum/anchor"; + +const uxdIdl: Idl = { + "version": "0.0.0", + "name": "uxd_ido", + "instructions": [ + { + "name": "initializePool", + "accounts": [ + { + "name": "poolAccount", + "isMut": true, + "isSigner": true + }, + { + "name": "poolSigner", + "isMut": false, + "isSigner": false + }, + { + "name": "redeemableMint", + "isMut": false, + "isSigner": false + }, + { + "name": "uxpMint", + "isMut": false, + "isSigner": false + }, + { + "name": "usdcMint", + "isMut": false, + "isSigner": false + }, + { + "name": "poolUxp", + "isMut": true, + "isSigner": false + }, + { + "name": "poolUsdc", + "isMut": false, + "isSigner": false + }, + { + "name": "distributionAuthority", + "isMut": true, + "isSigner": true + }, + { + "name": "creatorUxp", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "systemProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "rent", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "numIdoTokens", + "type": "u64" + }, + { + "name": "nonce", + "type": "u8" + }, + { + "name": "startIdoTs", + "type": "i64" + }, + { + "name": "endDepositsTs", + "type": "i64" + }, + { + "name": "endIdoTs", + "type": "i64" + } + ] + }, + { + "name": "exchangeUsdcForRedeemable", + "accounts": [ + { + "name": "poolAccount", + "isMut": false, + "isSigner": false + }, + { + "name": "poolSigner", + "isMut": false, + "isSigner": false + }, + { + "name": "redeemableMint", + "isMut": true, + "isSigner": false + }, + { + "name": "poolUsdc", + "isMut": true, + "isSigner": false + }, + { + "name": "userAuthority", + "isMut": false, + "isSigner": true + }, + { + "name": "userUsdc", + "isMut": true, + "isSigner": false + }, + { + "name": "userRedeemable", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "exchangeRedeemableForUsdc", + "accounts": [ + { + "name": "poolAccount", + "isMut": false, + "isSigner": false + }, + { + "name": "poolSigner", + "isMut": false, + "isSigner": false + }, + { + "name": "redeemableMint", + "isMut": true, + "isSigner": false + }, + { + "name": "poolUsdc", + "isMut": true, + "isSigner": false + }, + { + "name": "userAuthority", + "isMut": false, + "isSigner": true + }, + { + "name": "userUsdc", + "isMut": true, + "isSigner": false + }, + { + "name": "userRedeemable", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "exchangeRedeemableForUxp", + "accounts": [ + { + "name": "poolAccount", + "isMut": false, + "isSigner": false + }, + { + "name": "poolSigner", + "isMut": false, + "isSigner": false + }, + { + "name": "redeemableMint", + "isMut": true, + "isSigner": false + }, + { + "name": "poolUxp", + "isMut": true, + "isSigner": false + }, + { + "name": "userAuthority", + "isMut": false, + "isSigner": true + }, + { + "name": "userUxp", + "isMut": true, + "isSigner": false + }, + { + "name": "userRedeemable", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + } + ], + "args": [ + { + "name": "amount", + "type": "u64" + } + ] + }, + { + "name": "withdrawPoolUsdc", + "accounts": [ + { + "name": "poolAccount", + "isMut": false, + "isSigner": false + }, + { + "name": "poolSigner", + "isMut": false, + "isSigner": false + }, + { + "name": "poolUsdc", + "isMut": true, + "isSigner": false + }, + { + "name": "distributionAuthority", + "isMut": false, + "isSigner": true + }, + { + "name": "creatorUsdc", + "isMut": true, + "isSigner": false + }, + { + "name": "tokenProgram", + "isMut": false, + "isSigner": false + }, + { + "name": "clock", + "isMut": false, + "isSigner": false + } + ], + "args": [] + } + ], + "accounts": [ + { + "name": "PoolAccount", + "type": { + "kind": "struct", + "fields": [ + { + "name": "redeemableMint", + "type": "publicKey" + }, + { + "name": "poolUxp", + "type": "publicKey" + }, + { + "name": "uxpMint", + "type": "publicKey" + }, + { + "name": "poolUsdc", + "type": "publicKey" + }, + { + "name": "usdcMint", + "type": "publicKey" + }, + { + "name": "distributionAuthority", + "type": "publicKey" + }, + { + "name": "nonce", + "type": "u8" + }, + { + "name": "numIdoTokens", + "type": "u64" + }, + { + "name": "startIdoTs", + "type": "i64" + }, + { + "name": "endDepositsTs", + "type": "i64" + }, + { + "name": "endIdoTs", + "type": "i64" + } + ] + } + } + ], + "errors": [ + { + "code": 300, + "name": "IdoFuture", + "msg": "IDO must start in the future" + }, + { + "code": 301, + "name": "SeqTimes", + "msg": "IDO times are non-sequential" + }, + { + "code": 302, + "name": "StartIdoTime", + "msg": "IDO has not started" + }, + { + "code": 303, + "name": "EndDepositsTime", + "msg": "Deposits period has ended" + }, + { + "code": 304, + "name": "EndIdoTime", + "msg": "IDO has ended" + }, + { + "code": 305, + "name": "IdoNotOver", + "msg": "IDO has not finished yet" + }, + { + "code": 306, + "name": "InvalidAmount", + "msg": "Invalid amount passed to instruction. Should be not zero." + }, + { + "code": 307, + "name": "LowUsdc", + "msg": "Insufficient USDC" + }, + { + "code": 308, + "name": "LowRedeemable", + "msg": "Insufficient redeemable tokens" + }, + { + "code": 309, + "name": "UsdcNotEqRedeem", + "msg": "USDC total and redeemable total don't match" + }, + { + "code": 310, + "name": "InvalidNonce", + "msg": "Given nonce is invalid" + }, + { + "code": 311, + "name": "InvalidParam", + "msg": "Invalid param" + }, + { + "code": 312, + "name": "InvalidIdoAmount", + "msg": "Invalid Ido amount. There must be a positive amount of IDO token to distribute." + }, + { + "code": 313, + "name": "InvalidIdoEndTime", + "msg": "IDO cannot end before it starts." + }, + { + "code": 314, + "name": "InvalidIdoDepositEndTime", + "msg": "IDO cannot end before it starts." + } + ] + }; +export default uxdIdl; From b83124c36e5e1fa4c09f06ee43a1482934e6a17f Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 04:46:45 +0900 Subject: [PATCH 13/20] wip fix initialize IDO tx --- src/components/Multisig.tsx | 58 ++++++++++++++++++++++++------------- 1 file changed, 38 insertions(+), 20 deletions(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index ef415e4..d6e89d1 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -1026,7 +1026,6 @@ function InitializeIdoPoolListItemDetails({ variant: "info", }); const [,nonce] = await PublicKey.findProgramAddress([UXDIDOProgramAdress.toBuffer()], UXDIDOProgramAdress); - const data = initializeIdoPoolData(uxdClient, num_ido_tokens, nonce, start_ido_ts, end_deposits_ts, end_ido_ts); const [multisigSigner] = await PublicKey.findProgramAddress( [multisig.toBuffer()], multisigClient.programId @@ -1047,14 +1046,13 @@ function InitializeIdoPoolListItemDetails({ multisigSigner ); itxs.push(...redeemableMintItxs, ...poolUxpItxs, ...poolUsdcItxs); - + console.log({uxpMint}) // We use the uxp mint address as the seed, could use something else though. const [_poolSigner] = await anchor.web3.PublicKey.findProgramAddress( [uxpMint.toBuffer()], UXDIDOProgramAdress ); const poolSigner = _poolSigner; - const accounts = [ //? Do we need these two for some multisig stuff? // { @@ -1148,14 +1146,32 @@ function InitializeIdoPoolListItemDetails({ isSigner: false, }, ]; + const data = initializeIdoPoolData(uxdClient, num_ido_tokens, nonce, start_ido_ts, end_deposits_ts, end_ido_ts, { + poolAccount: poolAccount, + poolSigner, + distributionAuthority: multisigPDA, + redeemableMint, + usdcMint, + uxpMint, + poolUxp, + poolUsdc, + creatorUxp: uxpMultisigTokenAccount, + tokenProgram: TOKEN_PROGRAM_ID, + systemProgram: anchor.web3.SystemProgram.programId, + rent: anchor.web3.SYSVAR_RENT_PUBKEY, + clock: anchor.web3.SYSVAR_CLOCK_PUBKEY, + },); + console.log({data}) const transaction = new Keypair(); const txSize = 1000; // todo - - itxs.push((await multisigClient.account.transaction.createInstruction( - transaction, - // @ts-ignore - txSize - ))); + const txItx = (await multisigClient.account.transaction.createInstruction( + transaction, + // @ts-ignore + txSize + )); + console.log({txItx}) + itxs.push(txItx); + console.log({itxs}) const tx = await multisigClient.rpc.createTransaction( multisigClient.programId, accounts, @@ -1828,26 +1844,28 @@ function changeThresholdData(multisigClient, threshold) { } // @ts-ignore -function initializeIdoPoolData(uxdClient, +function initializeIdoPoolData(uxdClient: anchor.Program, num_ido_tokens: number, nonce: number, start_ido_ts: number, end_deposits_ts: number, - end_ido_ts: number + end_ido_ts: number, + accounts: any + ) { - return uxdClient.coder.instruction.encode("initialize_pool", { - num_ido_tokens: new BN(num_ido_tokens), - nonce: new BN(nonce), - start_ido_ts: new BN(start_ido_ts), - end_deposits_ts: new BN(end_deposits_ts), - end_ido_ts: new BN(end_ido_ts), - }); + return uxdClient.coder.instruction.encode("initialize_pool", uxdClient.instruction.initializePool( + new BN(num_ido_tokens), + new BN(nonce), + new BN(start_ido_ts), + new BN(end_deposits_ts), + new BN(end_ido_ts), + {accounts})) } // @ts-ignore -function withdrawIdoUsdcPoolData(uxdClient: any) { - return uxdClient.coder.instruction.encode("withdraw_pool_usdc"); +function withdrawIdoUsdcPoolData(uxdClient: anchor.Program) { + return uxdClient.coder.instruction.encode("withdraw_pool_usdc", {}); } // @ts-ignore From 38000a0ec88a25608f0959f268c9a11685e7b720 Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 11:35:18 +0900 Subject: [PATCH 14/20] still wip, encoding seems fine, small reorg, issue with undefined programId during tx signature --- src/components/Multisig.tsx | 614 +++++++++++++++++++----------------- src/utils/uxd_helper.ts | 3 +- 2 files changed, 326 insertions(+), 291 deletions(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index d6e89d1..e21769b 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -769,7 +769,7 @@ function AddTransactionDialog({ multisig={multisig} onClose={onClose} /> - void; + }) { + const [open, setOpen] = useState(false); + return ( + <> + setOpen((open) => !open)}> + + + + + {open ? : } + + + + + + ); +} + +function WithdrawIdoPoolListItem({ multisig, onClose, didAddTransaction, @@ -800,7 +832,7 @@ function WithdrawUSDCPoolListItem({ {open ? : } - void; }) { - const [open, setOpen] = useState(false); + + const [num_ido_tokens, setNum_ido_tokens] = useState(3); + const [start_ido_ts, setStart_ido_ts] = useState((Date.now()/1000) + 60 * 5); + const [end_deposits_ts, setEnd_deposits_ts] = useState((Date.now()/1000) + 60 * 10); + const [end_ido_ts, setEnd_ido_ts] = useState((Date.now()/1000) + 60 * 15); + const { multisigClient, uxdClient } = useWallet(); + // @ts-ignore + const { enqueueSnackbar } = useSnackbar(); + const initializeIdoPool = async () => { + enqueueSnackbar("Creating IDO pool initialization transaction", { + variant: "info", + }); + const [,nonce] = await PublicKey.findProgramAddress([UXDIDOProgramAdress.toBuffer()], UXDIDOProgramAdress); + const [multisigSigner] = await PublicKey.findProgramAddress( + [multisig.toBuffer()], + multisigClient.programId + ); + + const itxs = []; + const poolAccount = Keypair.generate(); + console.log("poolAccount: ", poolAccount.publicKey.toBase58()) + console.log("redeemableMint: "); + const {mint: redeemableMint, instructions: redeemableMintItxs} = await createMint(multisigClient.provider, multisigSigner); + console.log("poolUxp: "); + const {account: poolUxp, instructions: poolUxpItxs} = await createTokenAccount(multisigClient.provider, uxpMint, multisigSigner); + console.log("poolUsdc: "); + + const {account: poolUsdc, instructions: poolUsdcItxs} = await createTokenAccount( + multisigClient.provider, + usdcMint, + multisigSigner + ); + itxs.push(...redeemableMintItxs, ...poolUxpItxs, ...poolUsdcItxs); + console.log({uxpMint}) + // We use the uxp mint address as the seed, could use something else though. + const [_poolSigner] = await anchor.web3.PublicKey.findProgramAddress( + [uxpMint.toBuffer()], + UXDIDOProgramAdress + ); + const poolSigner = _poolSigner; + const accounts = [ + //? Do we need these two for some multisig stuff? + // { + // pubkey: multisig, + // isWritable: true, + // isSigner: false, + // }, + // { + // pubkey: multisigSigner, + // isWritable: false, + // isSigner: true, + // }, + // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. + // Accounts expected can be found here https://github.com/UXDProtocol/uxd_ido/blob/main/programs/uxd_ido/src/lib.rs#L281 + + // pool_account -- can be created arbitrarily - then will need to be referenced in the other operations and used on the front end (THE POINTER TO OUR IDO) + { + pubkey: poolAccount.publicKey, + isWritable: true, + isSigner: true, + }, + // pool_signer -- this is the multisig PDA : 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT + //? While testing we used to use a derivation from the uxp mint for creating this account + { + pubkey: poolSigner, + isWritable: false, + isSigner: false, + }, + // redeemable_mint -- Wrapped sollet USDC? which one do we use https://solscan.io/token/BXXkv6z8ykpG1yuvUDPgh732wzVHB69RnB9YgSYh3itW + // apparently we do not have to give a shit, jsute create a random mint account + { + pubkey: redeemableMint.publicKey, + isWritable: false, + isSigner: false, + }, + // uxp_mint -- This is UXP UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M token () https://solscan.io/token/UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M () + { + pubkey: uxpMint, + isWritable: false, + isSigner: false, + }, + // pool_uxp -- + { + pubkey: poolUxp.publicKey, + isWritable: true, + isSigner: false, + }, + // pool_usdc -- + { + pubkey: poolUsdc.publicKey, + isWritable: false, + isSigner: false, + }, + // distribution_authority -- should be the multisig PDA - might have an issue with the program cause it"s also a payer + // 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT + // NGMI if we discover issues last minute, this need to be done asap for our mental wellbeing, sorry to be lame but it"s super important + { + pubkey: multisigPDA, + isWritable: true, + isSigner: true, + }, + // creator_uxp -- Not sure what is this what was used before + //* It is the token account that holds the UXP that will be transfered to the uxpPool at initialization + { + pubkey: multisigUxpTokenAccount, + isWritable: true, + isSigner: false, + }, + // token_program + { + pubkey: TOKEN_PROGRAM_ID, + isWritable: false, + isSigner: false, + }, + // system_program + { + pubkey: anchor.web3.SystemProgram.programId, + isWritable: false, + isSigner: false, + }, + // rent + { + pubkey: anchor.web3.SYSVAR_RENT_PUBKEY, + isWritable: false, + isSigner: false, + }, + // clock + { + pubkey: anchor.web3.SYSVAR_CLOCK_PUBKEY, + isWritable: false, + isSigner: false, + }, + ]; + console.log({multisigUxpTokenAccount}) + const data = initializeIdoPoolData(uxdClient, num_ido_tokens, nonce, start_ido_ts, end_deposits_ts, end_ido_ts, + { + poolAccount: poolAccount.publicKey, + poolSigner, + distributionAuthority: multisigPDA, + redeemableMint: redeemableMint.publicKey, + usdcMint, + uxpMint, + poolUxp: poolUxp.publicKey, + poolUsdc: poolUsdc.publicKey, + creatorUxp: multisigUxpTokenAccount, + tokenProgram: TOKEN_PROGRAM_ID, + systemProgram: anchor.web3.SystemProgram.programId, + rent: anchor.web3.SYSVAR_RENT_PUBKEY, + clock: anchor.web3.SYSVAR_CLOCK_PUBKEY, + }, + poolAccount + ); + console.log({data}) + + const transaction = new Keypair(); + const txSize = 1000; // todo + const txItx = (await multisigClient.account.transaction.createInstruction( + transaction, + // @ts-ignore + txSize + )); + + itxs.push(txItx); + console.log({ + uxdClient: uxdClient.programId, + accounts, + data, + nestedAccounts: { + multisig, + transaction: transaction.publicKey, + proposer: multisigClient.provider.wallet.publicKey, + rent: SYSVAR_RENT_PUBKEY, + + }, + signers: [transaction], + instructions: [ + ...itxs + + ], + + + }) + console.log("itxs[0]", uxdClient.programId.toBase58()) + const tx = await multisigClient.rpc.createTransaction( + uxdClient.programId, + accounts, + data, + { + accounts: { + multisig, + transaction: transaction.publicKey, + proposer: multisigClient.provider.wallet.publicKey, + rent: SYSVAR_RENT_PUBKEY, + }, + signers: [transaction], + instructions: [ + itxs + ], + } + ); + enqueueSnackbar("Transaction created", { + variant: "success", + action: , + }); + didAddTransaction(transaction.publicKey); + onClose(); + }; return ( - <> - setOpen((open) => !open)}> - - - - - {open ? : } - - - - - +
+ { + // @ts-ignore + setNum_ido_tokens(e.target.value); + }} + /> + { + // @ts-ignore + setStart_ido_ts(e.target.value); + }} + /> + { + // @ts-ignore + setEnd_deposits_ts(e.target.value); + }} + /> + { + // @ts-ignore + setEnd_ido_ts(e.target.value); + }} + /> +
+ +
+
); } -// UXD MULTISIG instance AFBx8bHKmfqVxaHxgL8hLmrxJip8Dq8fZckngpQzVVG3 -// its PDA 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT (The one owning shits) -const UXDIDOProgramAdress = new PublicKey("UXDJHLPFr8qjLqZs8ejW24zFTq174g1wQHQ4LFhTXxz"); -const multisigPDA = new PublicKey("35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT"); //? Can we actually get that from the multisigClient? -const uxpMint = new PublicKey('MNDEFzGvMt87ueuHvVU9VcTqsAP5b3fTGPsHuuPA5ey');//new PublicKey("UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M"); -const usdcMint = new PublicKey("2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9"); //* That"s the mainnet one -const uxpMultisigTokenAccount = new PublicKey("GJgkVjjsYZeY2RLKcd7346A2dreykurTxkeNw6ysVQkc"); //! We should be able to get it from chain - -function WithdrawUSDCPoolListItemDetails({ +function WithdrawIdoPoolListItemDetails({ multisig, onClose, didAddTransaction, @@ -1004,257 +1283,6 @@ function WithdrawUSDCPoolListItemDetails({ ); } -function InitializeIdoPoolListItemDetails({ - multisig, - onClose, - didAddTransaction, -}: { - multisig: PublicKey; - onClose: Function; - didAddTransaction: (tx: PublicKey) => void; - }) { - - const [num_ido_tokens, setNum_ido_tokens] = useState(2); - const [start_ido_ts, setStart_ido_ts] = useState(2); - const [end_deposits_ts, setEnd_deposits_ts] = useState(2); - const [end_ido_ts, setEnd_ido_ts] = useState(2); - const { multisigClient, uxdClient } = useWallet(); - // @ts-ignore - const { enqueueSnackbar } = useSnackbar(); - const initializeIdoPool = async () => { - enqueueSnackbar("Creating IDO pool initialization transaction", { - variant: "info", - }); - const [,nonce] = await PublicKey.findProgramAddress([UXDIDOProgramAdress.toBuffer()], UXDIDOProgramAdress); - const [multisigSigner] = await PublicKey.findProgramAddress( - [multisig.toBuffer()], - multisigClient.programId - ); - - const itxs = []; - const poolAccount = Keypair.generate(); - console.log("poolAccount: ", poolAccount.publicKey.toBase58()) - console.log("redeemableMint: "); - const {mint: redeemableMint, instructions: redeemableMintItxs} = await createMint(multisigClient.provider, multisigSigner); - console.log("poolUxp: "); - const {account: poolUxp, instructions: poolUxpItxs} = await createTokenAccount(multisigClient.provider, uxpMint, multisigSigner); - console.log("poolUsdc: "); - - const {account: poolUsdc, instructions: poolUsdcItxs} = await createTokenAccount( - multisigClient.provider, - usdcMint, - multisigSigner - ); - itxs.push(...redeemableMintItxs, ...poolUxpItxs, ...poolUsdcItxs); - console.log({uxpMint}) - // We use the uxp mint address as the seed, could use something else though. - const [_poolSigner] = await anchor.web3.PublicKey.findProgramAddress( - [uxpMint.toBuffer()], - UXDIDOProgramAdress - ); - const poolSigner = _poolSigner; - const accounts = [ - //? Do we need these two for some multisig stuff? - // { - // pubkey: multisig, - // isWritable: true, - // isSigner: false, - // }, - // { - // pubkey: multisigSigner, - // isWritable: false, - // isSigner: true, - // }, - // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. - // Accounts expected can be found here https://github.com/UXDProtocol/uxd_ido/blob/main/programs/uxd_ido/src/lib.rs#L281 - - // pool_account -- can be created arbitrarily - then will need to be referenced in the other operations and used on the front end (THE POINTER TO OUR IDO) - { - pubkey: poolAccount.publicKey, - isWritable: true, - isSigner: true, - }, - // pool_signer -- this is the multisig PDA : 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT - //? While testing we used to use a derivation from the uxp mint for creating this account - { - pubkey: poolSigner, - isWritable: false, - isSigner: true, - }, - // redeemable_mint -- Wrapped sollet USDC? which one do we use https://solscan.io/token/BXXkv6z8ykpG1yuvUDPgh732wzVHB69RnB9YgSYh3itW - // apparently we do not have to give a shit, jsute create a random mint account - { - pubkey: redeemableMint, - isWritable: false, - isSigner: false, - }, - // uxp_mint -- This is UXP UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M token () https://solscan.io/token/UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M () - { - pubkey: new PublicKey("UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M"), - isWritable: false, - isSigner: false, - }, - // pool_uxp -- - { - pubkey: poolUxp, - isWritable: false, - isSigner: false, - }, - // pool_usdc -- - { - pubkey: poolUsdc, - isWritable: false, - isSigner: false, - }, - // distribution_authority -- should be the multisig PDA - might have an issue with the program cause it"s also a payer - // 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT - // NGMI if we discover issues last minute, this need to be done asap for our mental wellbeing, sorry to be lame but it"s super important - { - pubkey: multisigPDA, - isWritable: true, - isSigner: true, - }, - // creator_uxp -- Not sure what is this what was used before - //* It is the token account that holds the UXP that will be transfered to the uxpPool at initialization - { - pubkey: uxpMultisigTokenAccount, - isWritable: true, - isSigner: false, - }, - // token_program - { - pubkey: TOKEN_PROGRAM_ID, - isWritable: false, - isSigner: false, - }, - // system_program - { - pubkey: anchor.web3.SystemProgram.programId, - isWritable: false, - isSigner: false, - }, - // rent - { - pubkey: anchor.web3.SYSVAR_RENT_PUBKEY, - isWritable: false, - isSigner: false, - }, - // clock - { - pubkey: anchor.web3.SYSVAR_CLOCK_PUBKEY, - isWritable: false, - isSigner: false, - }, - ]; - const data = initializeIdoPoolData(uxdClient, num_ido_tokens, nonce, start_ido_ts, end_deposits_ts, end_ido_ts, { - poolAccount: poolAccount, - poolSigner, - distributionAuthority: multisigPDA, - redeemableMint, - usdcMint, - uxpMint, - poolUxp, - poolUsdc, - creatorUxp: uxpMultisigTokenAccount, - tokenProgram: TOKEN_PROGRAM_ID, - systemProgram: anchor.web3.SystemProgram.programId, - rent: anchor.web3.SYSVAR_RENT_PUBKEY, - clock: anchor.web3.SYSVAR_CLOCK_PUBKEY, - },); - console.log({data}) - const transaction = new Keypair(); - const txSize = 1000; // todo - const txItx = (await multisigClient.account.transaction.createInstruction( - transaction, - // @ts-ignore - txSize - )); - console.log({txItx}) - itxs.push(txItx); - console.log({itxs}) - const tx = await multisigClient.rpc.createTransaction( - multisigClient.programId, - accounts, - data, - { - accounts: { - multisig, - transaction: transaction.publicKey, - proposer: multisigClient.provider.wallet.publicKey, - rent: SYSVAR_RENT_PUBKEY, - }, - signers: [transaction], - instructions: [ - itxs - - ], - } - ); - enqueueSnackbar("Transaction created", { - variant: "success", - action: , - }); - didAddTransaction(transaction.publicKey); - onClose(); - }; - return ( -
- { - // @ts-ignore - setNum_ido_tokens(e.target.value); - }} - /> - { - // @ts-ignore - setStart_ido_ts(e.target.value); - }} - /> - { - // @ts-ignore - setEnd_deposits_ts(e.target.value); - }} - /> - { - // @ts-ignore - setEnd_ido_ts(e.target.value); - }} - /> -
- -
-
- ); -} function ChangeThresholdListItem({ multisig, @@ -1850,16 +1878,22 @@ function initializeIdoPoolData(uxdClient: anchor.Program, start_ido_ts: number, end_deposits_ts: number, end_ido_ts: number, - accounts: any - + accounts: any, + signer: Keypair ) { - return uxdClient.coder.instruction.encode("initialize_pool", uxdClient.instruction.initializePool( - new BN(num_ido_tokens), - new BN(nonce), - new BN(start_ido_ts), - new BN(end_deposits_ts), - new BN(end_ido_ts), - {accounts})) + return uxdClient.coder.instruction.encode( + "initialize_pool", + uxdClient.instruction.initializePool( + new BN(num_ido_tokens), + new BN(nonce), + new BN(start_ido_ts), + new BN(end_deposits_ts), + new BN(end_ido_ts), + { + accounts, + signers: [signer] + } + )); } diff --git a/src/utils/uxd_helper.ts b/src/utils/uxd_helper.ts index e52a3ba..f6421bf 100644 --- a/src/utils/uxd_helper.ts +++ b/src/utils/uxd_helper.ts @@ -4,7 +4,7 @@ import { TokenInstructions } from '@project-serum/serum'; // TODO: remove this constant once @project-serum/serum uses the same version // of @solana/web3.js as anchor (or switch packages). -const TOKEN_PROGRAM_ID = new anchor.web3.PublicKey(TokenInstructions.TOKEN_PROGRAM_ID.toString()); +const TOKEN_PROGRAM_ID = TokenInstructions.TOKEN_PROGRAM_ID; const ASSOC_TOKEN_PROGRAM_ID = new anchor.web3.PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL'); @@ -31,6 +31,7 @@ async function createMintInstructions( authority: anchor.web3.PublicKey, mint: anchor.web3.PublicKey ) { + console.log("TOKEN_PROGRAM_ID", TOKEN_PROGRAM_ID) let instructions = [ anchor.web3.SystemProgram.createAccount({ fromPubkey: provider.wallet.publicKey, From 5368abe82847a81aae191f9e2bcb77eed23b5f09 Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 14:14:42 +0900 Subject: [PATCH 15/20] encode itxs related to initializeIdo into data instead of passing in instructions array --- src/components/Multisig.tsx | 59 ++++++----------- src/components/WalletProvider.tsx | 10 +-- yarn.lock | 105 +----------------------------- 3 files changed, 27 insertions(+), 147 deletions(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index e21769b..2597bb5 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -98,7 +98,7 @@ function NewMultisigButton() { } export function MultisigInstance({ multisig }: { multisig: PublicKey }) { - const { multisigClient, uxdClient } = useWallet(); + const { multisigClient, idoClient } = useWallet(); const [multisigAccount, setMultisigAccount] = useState(undefined); const [transactions, setTransactions] = useState(null); const [showSignerDialog, setShowSignerDialog] = useState(false); @@ -866,7 +866,7 @@ function InitializeIdoPoolListItemDetails({ const [start_ido_ts, setStart_ido_ts] = useState((Date.now()/1000) + 60 * 5); const [end_deposits_ts, setEnd_deposits_ts] = useState((Date.now()/1000) + 60 * 10); const [end_ido_ts, setEnd_ido_ts] = useState((Date.now()/1000) + 60 * 15); - const { multisigClient, uxdClient } = useWallet(); + const { multisigClient, idoClient } = useWallet(); // @ts-ignore const { enqueueSnackbar } = useSnackbar(); const initializeIdoPool = async () => { @@ -995,7 +995,7 @@ function InitializeIdoPoolListItemDetails({ }, ]; console.log({multisigUxpTokenAccount}) - const data = initializeIdoPoolData(uxdClient, num_ido_tokens, nonce, start_ido_ts, end_deposits_ts, end_ido_ts, + const data = initializeIdoPoolData(idoClient, num_ido_tokens, nonce, start_ido_ts, end_deposits_ts, end_ido_ts, { poolAccount: poolAccount.publicKey, poolSigner, @@ -1011,7 +1011,8 @@ function InitializeIdoPoolListItemDetails({ rent: anchor.web3.SYSVAR_RENT_PUBKEY, clock: anchor.web3.SYSVAR_CLOCK_PUBKEY, }, - poolAccount + poolAccount, + itxs ); console.log({data}) @@ -1023,29 +1024,9 @@ function InitializeIdoPoolListItemDetails({ txSize )); - itxs.push(txItx); - console.log({ - uxdClient: uxdClient.programId, - accounts, - data, - nestedAccounts: { - multisig, - transaction: transaction.publicKey, - proposer: multisigClient.provider.wallet.publicKey, - rent: SYSVAR_RENT_PUBKEY, - - }, - signers: [transaction], - instructions: [ - ...itxs - - ], - - - }) - console.log("itxs[0]", uxdClient.programId.toBase58()) + const tx = await multisigClient.rpc.createTransaction( - uxdClient.programId, + idoClient.programId, accounts, data, { @@ -1057,7 +1038,7 @@ function InitializeIdoPoolListItemDetails({ }, signers: [transaction], instructions: [ - itxs + txItx ], } ); @@ -1116,12 +1097,12 @@ function InitializeIdoPoolListItemDetails({ value={end_ido_ts} type="number" onChange={(e) => { - // @ts-ignore + // @ts-ignore setEnd_ido_ts(e.target.value); }} />
- +
); @@ -1138,7 +1119,7 @@ function WithdrawIdoPoolListItemDetails({ }) { const [poolAccountAddr, setPoolAccountAddr] = useState(""); const [poolUsdcAddr, setPoolUsdcAddr] = useState(""); - const { multisigClient, uxdClient } = useWallet(); + const { multisigClient, idoClient } = useWallet(); const { enqueueSnackbar } = useSnackbar(); const withdrawIdoPool = async () => { @@ -1160,7 +1141,7 @@ function WithdrawIdoPoolListItemDetails({ variant: "info", }); - const data = withdrawIdoUsdcPoolData(uxdClient); + const data = withdrawIdoUsdcPoolData(idoClient); const accounts = [ // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. @@ -1872,18 +1853,19 @@ function changeThresholdData(multisigClient, threshold) { } // @ts-ignore -function initializeIdoPoolData(uxdClient: anchor.Program, +function initializeIdoPoolData(idoClient: anchor.Program, num_ido_tokens: number, nonce: number, start_ido_ts: number, end_deposits_ts: number, end_ido_ts: number, accounts: any, - signer: Keypair + signer: Keypair, + itxs: anchor.web3.TransactionInstruction[] ) { - return uxdClient.coder.instruction.encode( + return idoClient.coder.instruction.encode( "initialize_pool", - uxdClient.instruction.initializePool( + idoClient.instruction.initializePool( new BN(num_ido_tokens), new BN(nonce), new BN(start_ido_ts), @@ -1891,15 +1873,16 @@ function initializeIdoPoolData(uxdClient: anchor.Program, new BN(end_ido_ts), { accounts, - signers: [signer] + signers: [signer], + instructions: [...itxs] } )); } // @ts-ignore -function withdrawIdoUsdcPoolData(uxdClient: anchor.Program) { - return uxdClient.coder.instruction.encode("withdraw_pool_usdc", {}); +function withdrawIdoUsdcPoolData(idoClient: anchor.Program) { + return idoClient.coder.instruction.encode("withdraw_pool_usdc", {}); } // @ts-ignore diff --git a/src/components/WalletProvider.tsx b/src/components/WalletProvider.tsx index a9190cb..5078d17 100644 --- a/src/components/WalletProvider.tsx +++ b/src/components/WalletProvider.tsx @@ -28,7 +28,7 @@ const WalletContext = React.createContext(null); type WalletContextValues = { wallet: Wallet; multisigClient: Program; - uxdClient: Program + idoClient: Program }; export default function WalletProvider( @@ -41,7 +41,7 @@ export default function WalletProvider( }; }); - const { wallet, multisigClient, uxdClient } = useMemo(() => { + const { wallet, multisigClient, idoClient } = useMemo(() => { const opts: ConfirmOptions = { preflightCommitment: "recent", commitment: "recent", @@ -58,7 +58,7 @@ export default function WalletProvider( const UXDIDOProgramAdress = new web3.PublicKey("UXDJHLPFr8qjLqZs8ejW24zFTq174g1wQHQ4LFhTXxz"); - const uxdClient = new Program( + const idoClient = new Program( uxdIdl, UXDIDOProgramAdress, provider @@ -67,12 +67,12 @@ export default function WalletProvider( return { wallet, multisigClient, - uxdClient + idoClient }; }, [walletProvider, network]); return ( - + {props.children} ); diff --git a/yarn.lock b/yarn.lock index a6be1cf..1e012b8 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1191,27 +1191,6 @@ minimatch "^3.0.4" strip-json-comments "^3.1.1" -"@ethersproject/bytes@^5.5.0": - version "5.5.0" - resolved "https://registry.yarnpkg.com/@ethersproject/bytes/-/bytes-5.5.0.tgz#cb11c526de657e7b45d2e0f0246fb3b9d29a601c" - integrity sha512-ABvc7BHWhZU9PNM/tANm/Qx4ostPGadAuQzWTr3doklZOhDlmcBqclrQe/ZXUIj3K8wC28oYeuRa+A37tX9kog== - dependencies: - "@ethersproject/logger" "^5.5.0" - -"@ethersproject/logger@^5.5.0": - version "5.5.0" - resolved "https://registry.yarnpkg.com/@ethersproject/logger/-/logger-5.5.0.tgz#0c2caebeff98e10aefa5aef27d7441c7fd18cf5d" - integrity sha512-rIY/6WPm7T8n3qS2vuHTUBPdXHl+rGxWxW5okDfo9J4Z0+gRRZT0msvUdIJkE4/HS29GUMziwGaaKO2bWONBrg== - -"@ethersproject/sha2@^5.5.0": - version "5.5.0" - resolved "https://registry.yarnpkg.com/@ethersproject/sha2/-/sha2-5.5.0.tgz#a40a054c61f98fd9eee99af2c3cc6ff57ec24db7" - integrity sha512-B5UBoglbCiHamRVPLA110J+2uqsifpZaTmid2/7W5rbtYVz6gus6/hSDieIU/6gaKIDcOj12WnOdiymEUHIAOA== - dependencies: - "@ethersproject/bytes" "^5.5.0" - "@ethersproject/logger" "^5.5.0" - hash.js "1.1.7" - "@hapi/address@2.x.x": version "2.1.4" resolved "https://registry.yarnpkg.com/@hapi/address/-/address-2.1.4.tgz#5d67ed43f3fd41a69d4b9ff7b56e7c0d1d0a81e5" @@ -1431,17 +1410,6 @@ "@types/yargs" "^15.0.0" chalk "^4.0.0" -"@jest/types@^27.2.5": - version "27.2.5" - resolved "https://registry.yarnpkg.com/@jest/types/-/types-27.2.5.tgz#420765c052605e75686982d24b061b4cbba22132" - integrity sha512-nmuM4VuDtCZcY+eTpw+0nvstwReMsjPoj7ZR80/BbixulhLaiX+fbv8oeLW8WZlJMcsGQsTmMKT/iTZu1Uy/lQ== - dependencies: - "@types/istanbul-lib-coverage" "^2.0.0" - "@types/istanbul-reports" "^3.0.0" - "@types/node" "*" - "@types/yargs" "^16.0.0" - chalk "^4.0.0" - "@material-ui/core@^4.11.3": version "4.11.3" resolved "https://registry.yarnpkg.com/@material-ui/core/-/core-4.11.3.tgz#f22e41775b0bd075e36a7a093d43951bf7f63850" @@ -1739,26 +1707,6 @@ superstruct "^0.14.2" tweetnacl "^1.0.0" -"@solana/web3.js@^1.30.2": - version "1.30.2" - resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.30.2.tgz#e85da75e0825dc64f53eb64a1ff0115b27bec135" - integrity sha512-hznCj+rkfvM5taRP3Z+l5lumB7IQnDrB4l55Wpsg4kDU9Zds8pE5YOH5Z9bbF/pUzZJKQjyBjnY/6kScBm3Ugg== - dependencies: - "@babel/runtime" "^7.12.5" - "@ethersproject/sha2" "^5.5.0" - "@solana/buffer-layout" "^3.0.0" - bn.js "^5.0.0" - borsh "^0.4.0" - bs58 "^4.0.1" - buffer "6.0.1" - cross-fetch "^3.1.4" - jayson "^3.4.4" - js-sha3 "^0.8.0" - rpc-websockets "^7.4.2" - secp256k1 "^4.0.2" - superstruct "^0.14.2" - tweetnacl "^1.0.0" - "@surma/rollup-plugin-off-main-thread@^1.1.1": version "1.4.2" resolved "https://registry.yarnpkg.com/@surma/rollup-plugin-off-main-thread/-/rollup-plugin-off-main-thread-1.4.2.tgz#e6786b6af5799f82f7ab3a82e53f6182d2b91a58" @@ -1870,20 +1818,6 @@ "@svgr/plugin-svgo" "^5.5.0" loader-utils "^2.0.0" -"@testing-library/dom@>=8.11.0": - version "8.11.0" - resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.11.0.tgz#3679dfb4db58e0d2b95e4b0929eaf45237b60d94" - integrity sha512-8Ay4UDiMlB5YWy+ZvCeRyFFofs53ebxrWnOFvCoM1HpMAX4cHyuSrCuIM9l2lVuUWUt+Gr3loz/nCwdrnG6ShQ== - dependencies: - "@babel/code-frame" "^7.10.4" - "@babel/runtime" "^7.12.5" - "@types/aria-query" "^4.2.0" - aria-query "^5.0.0" - chalk "^4.1.0" - dom-accessibility-api "^0.5.9" - lz-string "^1.4.4" - pretty-format "^27.0.2" - "@testing-library/dom@^7.28.1": version "7.30.4" resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.30.4.tgz#c6a4a91557e92035fd565246bbbfb8107aa4634d" @@ -2260,13 +2194,6 @@ dependencies: "@types/yargs-parser" "*" -"@types/yargs@^16.0.0": - version "16.0.4" - resolved "https://registry.yarnpkg.com/@types/yargs/-/yargs-16.0.4.tgz#26aad98dd2c2a38e421086ea9ad42b9e51642977" - integrity sha512-T8Yc9wt/5LbJyCaLiHPReJa0kApcIgJ7Bn735GjItUfh08Z1pJvu8QZqb9s+mMvKV6WUQRV7K2R46YbjMXTTJw== - dependencies: - "@types/yargs-parser" "*" - "@typescript-eslint/eslint-plugin@^4.5.0": version "4.15.2" resolved "https://registry.yarnpkg.com/@typescript-eslint/eslint-plugin/-/eslint-plugin-4.15.2.tgz#981b26b4076c62a5a55873fbef3fe98f83360c61" @@ -2671,11 +2598,6 @@ ansi-regex@^5.0.0: resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.0.tgz#388539f55179bf39339c81af30a654d69f87cb75" integrity sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg== -ansi-regex@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304" - integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ== - ansi-styles@^3.2.0, ansi-styles@^3.2.1: version "3.2.1" resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-3.2.1.tgz#41fbb20243e50b12be0f04b8dedbf07520ce841d" @@ -2690,11 +2612,6 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0: dependencies: color-convert "^2.0.1" -ansi-styles@^5.0.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b" - integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA== - any-promise@^1.0.0: version "1.3.0" resolved "https://registry.yarnpkg.com/any-promise/-/any-promise-1.3.0.tgz#abc6afeedcea52e809cdc0376aed3ce39635d17f" @@ -2736,11 +2653,6 @@ aria-query@^4.2.2: "@babel/runtime" "^7.10.2" "@babel/runtime-corejs3" "^7.10.2" -aria-query@^5.0.0: - version "5.0.0" - resolved "https://registry.yarnpkg.com/aria-query/-/aria-query-5.0.0.tgz#210c21aaf469613ee8c9a62c7f86525e058db52c" - integrity sha512-V+SM7AbUwJ+EBnB8+DXs0hPZHO0W6pqBcc0dW90OwtVG02PswOu/teuARoLQjdDOH+t9pJgGnW5/Qmouf3gPJg== - arity-n@^1.0.4: version "1.0.4" resolved "https://registry.yarnpkg.com/arity-n/-/arity-n-1.0.4.tgz#d9e76b11733e08569c0847ae7b39b2860b30b745" @@ -4683,11 +4595,6 @@ dom-accessibility-api@^0.5.4: resolved "https://registry.yarnpkg.com/dom-accessibility-api/-/dom-accessibility-api-0.5.4.tgz#b06d059cdd4a4ad9a79275f9d414a5c126241166" integrity sha512-TvrjBckDy2c6v6RLxPv5QXOnU+SmF9nBII5621Ve5fu6Z/BDrENurBEvlC1f44lKEUVqOpK4w9E5Idc5/EgkLQ== -dom-accessibility-api@^0.5.9: - version "0.5.10" - resolved "https://registry.yarnpkg.com/dom-accessibility-api/-/dom-accessibility-api-0.5.10.tgz#caa6d08f60388d0bb4539dd75fe458a9a1d0014c" - integrity sha512-Xu9mD0UjrJisTmv7lmVSDMagQcU9R5hwAbxsaAE/35XPnPLJobbuREfV/rraiSaEj/UOvgrzQs66zyTWTlyd+g== - dom-converter@^0.2: version "0.2.0" resolved "https://registry.yarnpkg.com/dom-converter/-/dom-converter-0.2.0.tgz#6721a9daee2e293682955b6afe416771627bb768" @@ -6099,7 +6006,7 @@ hash-base@^3.0.0: readable-stream "^3.6.0" safe-buffer "^5.2.0" -hash.js@1.1.7, hash.js@^1.0.0, hash.js@^1.0.3: +hash.js@^1.0.0, hash.js@^1.0.3: version "1.1.7" resolved "https://registry.yarnpkg.com/hash.js/-/hash.js-1.1.7.tgz#0babca538e8d4ee4a0f8988d68866537a003cf42" integrity sha512-taOaskGt4z4SOANNseOviYDvjEJinIkRgmp7LbKP2YTTmVxWBl87s/uzK9r+44BclBSp2X7K1hqeNfz9JbBeXA== @@ -9792,16 +9699,6 @@ pretty-format@^26.0.0, pretty-format@^26.6.0, pretty-format@^26.6.2: ansi-styles "^4.0.0" react-is "^17.0.1" -pretty-format@^27.0.2: - version "27.3.1" - resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.3.1.tgz#7e9486365ccdd4a502061fa761d3ab9ca1b78df5" - integrity sha512-DR/c+pvFc52nLimLROYjnXPtolawm+uWDxr4FjuLDLUn+ktWnSN851KoHwHzzqq6rfCOjkzN8FLgDrSub6UDuA== - dependencies: - "@jest/types" "^27.2.5" - ansi-regex "^5.0.1" - ansi-styles "^5.0.0" - react-is "^17.0.1" - process-nextick-args@~2.0.0: version "2.0.1" resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-2.0.1.tgz#7820d9b16120cc55ca9ae7792680ae7dba6d7fe2" From 59e97a75f6b92a6571254a013cd9d3b93b858de4 Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 15:54:51 +0900 Subject: [PATCH 16/20] rework withdrawIdoPool --- src/components/Multisig.tsx | 72 +++++++++++++++++++++---------------- 1 file changed, 42 insertions(+), 30 deletions(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index 2597bb5..ff96cc5 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -98,7 +98,7 @@ function NewMultisigButton() { } export function MultisigInstance({ multisig }: { multisig: PublicKey }) { - const { multisigClient, idoClient } = useWallet(); + const { multisigClient } = useWallet(); const [multisigAccount, setMultisigAccount] = useState(undefined); const [transactions, setTransactions] = useState(null); const [showSignerDialog, setShowSignerDialog] = useState(false); @@ -894,7 +894,6 @@ function InitializeIdoPoolListItemDetails({ multisigSigner ); itxs.push(...redeemableMintItxs, ...poolUxpItxs, ...poolUsdcItxs); - console.log({uxpMint}) // We use the uxp mint address as the seed, could use something else though. const [_poolSigner] = await anchor.web3.PublicKey.findProgramAddress( [uxpMint.toBuffer()], @@ -902,17 +901,7 @@ function InitializeIdoPoolListItemDetails({ ); const poolSigner = _poolSigner; const accounts = [ - //? Do we need these two for some multisig stuff? - // { - // pubkey: multisig, - // isWritable: true, - // isSigner: false, - // }, - // { - // pubkey: multisigSigner, - // isWritable: false, - // isSigner: true, - // }, + // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. // Accounts expected can be found here https://github.com/UXDProtocol/uxd_ido/blob/main/programs/uxd_ido/src/lib.rs#L281 @@ -994,8 +983,8 @@ function InitializeIdoPoolListItemDetails({ isSigner: false, }, ]; - console.log({multisigUxpTokenAccount}) - const data = initializeIdoPoolData(idoClient, num_ido_tokens, nonce, start_ido_ts, end_deposits_ts, end_ido_ts, + + const data = initializeIdoPoolData(idoClient, num_ido_tokens, nonce, start_ido_ts, end_deposits_ts, end_ido_ts, { poolAccount: poolAccount.publicKey, poolSigner, @@ -1014,7 +1003,6 @@ function InitializeIdoPoolListItemDetails({ poolAccount, itxs ); - console.log({data}) const transaction = new Keypair(); const txSize = 1000; // todo @@ -1124,10 +1112,10 @@ function WithdrawIdoPoolListItemDetails({ const { enqueueSnackbar } = useSnackbar(); const withdrawIdoPool = async () => { const itxs: anchor.web3.TransactionInstruction[] = []; - let multisigUsdc = findAssociatedTokenAddress(multisigPDA, usdcMint) - if (!multisigUsdc) { + let multisigUsdcTokenAccount = findAssociatedTokenAddress(multisigPDA, usdcMint) + if (!multisigUsdcTokenAccount) { const { account: multisigUsdcAcc, instructions: createmultisigUsdcItxs} = await createTokenAccount(multisigClient.provider, usdcMint, multisigPDA); - multisigUsdc= multisigUsdcAcc.publicKey + multisigUsdcTokenAccount = multisigUsdcAcc.publicKey itxs.push(...createmultisigUsdcItxs); } // We use the uxp mint address as the seed, could use something else though. @@ -1141,15 +1129,15 @@ function WithdrawIdoPoolListItemDetails({ variant: "info", }); - const data = withdrawIdoUsdcPoolData(idoClient); - + const poolAccountKey = new PublicKey(poolAccountAddr) + const poolUsdcKey = new PublicKey(poolUsdcAddr) const accounts = [ // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. // Accounts expected can be found here https://github.com/UXDProtocol/uxd_ido/blob/main/programs/uxd_ido/src/lib.rs#L281 // pool_account -- can be created arbitrarily - then will need to be referenced in the other operations and used on the front end (THE POINTER TO OUR IDO) { - pubkey: new PublicKey(poolAccountAddr), + pubkey: poolAccountKey, isWritable: true, isSigner: true, }, @@ -1163,7 +1151,7 @@ function WithdrawIdoPoolListItemDetails({ // pool_usdc -- { - pubkey: new PublicKey(poolUsdcAddr), + pubkey: poolUsdcKey, isWritable: false, isSigner: false, }, @@ -1177,7 +1165,7 @@ function WithdrawIdoPoolListItemDetails({ }, // creator_usdc -- is actually the token account that will receive the usdc { - pubkey: multisigUsdc, + pubkey: multisigUsdcTokenAccount, isWritable: true, isSigner: false, }, @@ -1195,15 +1183,32 @@ function WithdrawIdoPoolListItemDetails({ isSigner: false, }, ]; + + const data = withdrawIdoUsdcPoolData( + idoClient, + { + poolAccount: poolAccountKey, + poolSigner, + distributionAuthority: multisigPDA, + creatorUsdc: multisigUsdcTokenAccount, + poolUsdc: poolUsdcKey, + tokenProgram: TOKEN_PROGRAM_ID, + clock: anchor.web3.SYSVAR_CLOCK_PUBKEY, + }, + itxs + ); + + const transaction = new Keypair(); const txSize = 1000; // todo - itxs.push((await multisigClient.account.transaction.createInstruction( + const txItx = await multisigClient.account.transaction.createInstruction( transaction, // @ts-ignore txSize - ))); + ); + const tx = await multisigClient.rpc.createTransaction( - multisigClient.programId, + idoClient.programId, accounts, data, { @@ -1216,7 +1221,7 @@ function WithdrawIdoPoolListItemDetails({ signers: [transaction], instructions: [ - ...itxs + txItx ], } ); @@ -1881,8 +1886,15 @@ function initializeIdoPoolData(idoClient: anchor.Program, // @ts-ignore -function withdrawIdoUsdcPoolData(idoClient: anchor.Program) { - return idoClient.coder.instruction.encode("withdraw_pool_usdc", {}); +function withdrawIdoUsdcPoolData(idoClient: anchor.Program, accounts: any, itxs: anchor.web3.TransactionInstruction[]) { + return idoClient.coder.instruction.encode( + "withdraw_pool_usdc", + idoClient.instruction.withdrawPoolUsdc( + { + accounts, + instructions: [...itxs] + } + )); } // @ts-ignore From e0e6d22e4a67b76529b7ce13caedb745534b8794 Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 16:15:09 +0900 Subject: [PATCH 17/20] small refacto for more clarity --- src/components/Multisig.tsx | 24 +++++++++++++----------- src/components/WalletProvider.tsx | 4 ++-- src/idl/{controllerUXD.ts => idoIdl.ts} | 0 3 files changed, 15 insertions(+), 13 deletions(-) rename src/idl/{controllerUXD.ts => idoIdl.ts} (100%) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index ff96cc5..4503523 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -844,7 +844,7 @@ function WithdrawIdoPoolListItem({ // UXD MULTISIG instance AFBx8bHKmfqVxaHxgL8hLmrxJip8Dq8fZckngpQzVVG3 // its PDA 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT (The one owning shits) -const UXDIDOProgramAdress = new PublicKey("UXDJHLPFr8qjLqZs8ejW24zFTq174g1wQHQ4LFhTXxz"); +const IdoProgramAddress = new PublicKey("UXDJHLPFr8qjLqZs8ejW24zFTq174g1wQHQ4LFhTXxz"); const multisigPDA = new PublicKey("35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT"); //? Can we actually get that from the multisigClient? const uxpMint = new PublicKey('MNDEFzGvMt87ueuHvVU9VcTqsAP5b3fTGPsHuuPA5ey');//new PublicKey("UXPhBoR3qG4UCiGNJfV7MqhHyFqKN68g45GoYvAeL2M"); const usdcMint = new PublicKey("2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9"); //* That"s the mainnet one @@ -873,7 +873,7 @@ function InitializeIdoPoolListItemDetails({ enqueueSnackbar("Creating IDO pool initialization transaction", { variant: "info", }); - const [,nonce] = await PublicKey.findProgramAddress([UXDIDOProgramAdress.toBuffer()], UXDIDOProgramAdress); + const [,nonce] = await PublicKey.findProgramAddress([IdoProgramAddress.toBuffer()], IdoProgramAddress); const [multisigSigner] = await PublicKey.findProgramAddress( [multisig.toBuffer()], multisigClient.programId @@ -897,9 +897,10 @@ function InitializeIdoPoolListItemDetails({ // We use the uxp mint address as the seed, could use something else though. const [_poolSigner] = await anchor.web3.PublicKey.findProgramAddress( [uxpMint.toBuffer()], - UXDIDOProgramAdress + IdoProgramAddress ); const poolSigner = _poolSigner; + const distributionAuthority = multisigPDA; const accounts = [ // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. @@ -947,7 +948,7 @@ function InitializeIdoPoolListItemDetails({ // 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT // NGMI if we discover issues last minute, this need to be done asap for our mental wellbeing, sorry to be lame but it"s super important { - pubkey: multisigPDA, + pubkey: distributionAuthority, isWritable: true, isSigner: true, }, @@ -1121,7 +1122,7 @@ function WithdrawIdoPoolListItemDetails({ // We use the uxp mint address as the seed, could use something else though. const [_poolSigner] = await anchor.web3.PublicKey.findProgramAddress( [uxpMint.toBuffer()], - UXDIDOProgramAdress + IdoProgramAddress ); const poolSigner = _poolSigner; // @ts-ignore @@ -1131,6 +1132,7 @@ function WithdrawIdoPoolListItemDetails({ const poolAccountKey = new PublicKey(poolAccountAddr) const poolUsdcKey = new PublicKey(poolUsdcAddr) + const distributionAuthority = multisigPDA; const accounts = [ // HERE NEED TO ADD THE RIGHT ACCOUNTS -- Not sure what can be hardcoded or not your call for now. // Accounts expected can be found here https://github.com/UXDProtocol/uxd_ido/blob/main/programs/uxd_ido/src/lib.rs#L281 @@ -1138,29 +1140,29 @@ function WithdrawIdoPoolListItemDetails({ // pool_account -- can be created arbitrarily - then will need to be referenced in the other operations and used on the front end (THE POINTER TO OUR IDO) { pubkey: poolAccountKey, - isWritable: true, - isSigner: true, + isWritable: false, + isSigner: false, }, // pool_signer -- this is the multisig PDA : 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT //? While testing we used to use a derivation from the uxp mint for creating this account { pubkey: poolSigner, isWritable: false, - isSigner: true, + isSigner: false, }, // pool_usdc -- { pubkey: poolUsdcKey, - isWritable: false, + isWritable: true, isSigner: false, }, // distribution_authority -- should be the multisig PDA - might have an issue with the program cause it"s also a payer // 35F3GaWyShU5N5ygYAFWDw6bGVNHnAHSe8RKzqRD2RkT // NGMI if we discover issues last minute, this need to be done asap for our mental wellbeing, sorry to be lame but it"s super important { - pubkey: multisigPDA, - isWritable: true, + pubkey: distributionAuthority, + isWritable: false, isSigner: true, }, // creator_usdc -- is actually the token account that will receive the usdc diff --git a/src/components/WalletProvider.tsx b/src/components/WalletProvider.tsx index 5078d17..b07852c 100644 --- a/src/components/WalletProvider.tsx +++ b/src/components/WalletProvider.tsx @@ -12,7 +12,7 @@ import Wallet from "@project-serum/sol-wallet-adapter"; import { Program, Provider, web3 } from "@project-serum/anchor"; import { State as StoreState } from "../store/reducer"; import MultisigIdl from "../idl"; -import uxdIdl from "../idl/controllerUXD"; +import idoIdl from "../idl/idoIdl"; export function useWallet(): WalletContextValues { const w = useContext(WalletContext); @@ -59,7 +59,7 @@ export default function WalletProvider( const UXDIDOProgramAdress = new web3.PublicKey("UXDJHLPFr8qjLqZs8ejW24zFTq174g1wQHQ4LFhTXxz"); const idoClient = new Program( - uxdIdl, + idoIdl, UXDIDOProgramAdress, provider ) diff --git a/src/idl/controllerUXD.ts b/src/idl/idoIdl.ts similarity index 100% rename from src/idl/controllerUXD.ts rename to src/idl/idoIdl.ts From 6aeb0cbcfa3cb90129f90f5b1e228523edf99925 Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 17:47:04 +0900 Subject: [PATCH 18/20] add wallet in signers --- src/components/Multisig.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index 4503523..d3e422a 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -864,8 +864,8 @@ function InitializeIdoPoolListItemDetails({ const [num_ido_tokens, setNum_ido_tokens] = useState(3); const [start_ido_ts, setStart_ido_ts] = useState((Date.now()/1000) + 60 * 5); - const [end_deposits_ts, setEnd_deposits_ts] = useState((Date.now()/1000) + 60 * 10); - const [end_ido_ts, setEnd_ido_ts] = useState((Date.now()/1000) + 60 * 15); + const [end_deposits_ts, setEnd_deposits_ts] = useState((Date.now()/1000) + 60 * 7); + const [end_ido_ts, setEnd_ido_ts] = useState((Date.now()/1000) + 60 * 10); const { multisigClient, idoClient } = useWallet(); // @ts-ignore const { enqueueSnackbar } = useSnackbar(); @@ -1025,7 +1025,7 @@ function InitializeIdoPoolListItemDetails({ proposer: multisigClient.provider.wallet.publicKey, rent: SYSVAR_RENT_PUBKEY, }, - signers: [transaction], + signers: [transaction, multisigClient.provider.wallet], instructions: [ txItx ], From 5c7e868a98583b21d22e4cc94b4a68c6222a5b67 Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 17:52:12 +0900 Subject: [PATCH 19/20] remove wallet from signers --- src/components/Multisig.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index d3e422a..1df0cb5 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -1025,7 +1025,7 @@ function InitializeIdoPoolListItemDetails({ proposer: multisigClient.provider.wallet.publicKey, rent: SYSVAR_RENT_PUBKEY, }, - signers: [transaction, multisigClient.provider.wallet], + signers: [transaction], instructions: [ txItx ], From 87dee9bbb70e7634a9d694491b437f3f83bd0e15 Mon Sep 17 00:00:00 2001 From: Thomas Proust Date: Sun, 7 Nov 2021 18:11:07 +0900 Subject: [PATCH 20/20] remove signers for top tx --- src/components/Multisig.tsx | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/components/Multisig.tsx b/src/components/Multisig.tsx index 1df0cb5..70ae23f 100644 --- a/src/components/Multisig.tsx +++ b/src/components/Multisig.tsx @@ -457,6 +457,7 @@ function TxListItem({ [multisig.toBuffer()], multisigClient.programId ); + console.log({tx: tx.publicKey}) await multisigClient.rpc.executeTransaction({ accounts: { multisig, @@ -950,7 +951,7 @@ function InitializeIdoPoolListItemDetails({ { pubkey: distributionAuthority, isWritable: true, - isSigner: true, + isSigner: false, }, // creator_uxp -- Not sure what is this what was used before //* It is the token account that holds the UXP that will be transfered to the uxpPool at initialization @@ -1025,7 +1026,7 @@ function InitializeIdoPoolListItemDetails({ proposer: multisigClient.provider.wallet.publicKey, rent: SYSVAR_RENT_PUBKEY, }, - signers: [transaction], + signers: [transaction, poolAccount], instructions: [ txItx ],