@depay/web3-wallets-evm 14.5.2 → 14.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/esm/index.evm.js +129 -52
- package/dist/esm/index.js +129 -52
- package/dist/umd/index.evm.js +129 -52
- package/dist/umd/index.js +129 -52
- package/package.json +1 -1
package/dist/esm/index.evm.js
CHANGED
|
@@ -59891,6 +59891,97 @@ const getProvider = async (blockchain)=>{
|
|
|
59891
59891
|
}
|
|
59892
59892
|
};
|
|
59893
59893
|
|
|
59894
|
+
class Argent {
|
|
59895
|
+
|
|
59896
|
+
constructor ({ address, blockchain }) {
|
|
59897
|
+
this.address = address;
|
|
59898
|
+
this.blockchain = blockchain;
|
|
59899
|
+
}
|
|
59900
|
+
|
|
59901
|
+
async transactionCount() {
|
|
59902
|
+
return 1 // irrelevant as proxy address/relayer actually sending the transaction is not known yet (but needs to be something)
|
|
59903
|
+
}
|
|
59904
|
+
}
|
|
59905
|
+
|
|
59906
|
+
const blockchainNames = {
|
|
59907
|
+
'ethereum': 'mainnet',
|
|
59908
|
+
'bsc': 'bsc',
|
|
59909
|
+
'polygon': 'polygon',
|
|
59910
|
+
};
|
|
59911
|
+
|
|
59912
|
+
class Safe {
|
|
59913
|
+
|
|
59914
|
+
constructor ({ address, blockchain }) {
|
|
59915
|
+
this.address = address;
|
|
59916
|
+
this.blockchain = blockchain;
|
|
59917
|
+
}
|
|
59918
|
+
|
|
59919
|
+
async transactionCount() {
|
|
59920
|
+
return parseInt((await request({
|
|
59921
|
+
blockchain: this.blockchain,
|
|
59922
|
+
address: this.address,
|
|
59923
|
+
api: [{"inputs":[],"name":"nonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}],
|
|
59924
|
+
method: 'nonce',
|
|
59925
|
+
})).toString(), 10)
|
|
59926
|
+
}
|
|
59927
|
+
|
|
59928
|
+
async retrieveTransaction({ blockchain, tx }) {
|
|
59929
|
+
const provider = await getProvider(blockchain);
|
|
59930
|
+
let jsonResult = await fetch(`https://safe-transaction-${blockchainNames[blockchain]}.safe.global/api/v1/multisig-transactions/${tx}/`)
|
|
59931
|
+
.then((response) => response.json())
|
|
59932
|
+
.catch((error) => { console.error('Error:', error); });
|
|
59933
|
+
if(jsonResult && jsonResult.isExecuted && jsonResult.transactionHash) {
|
|
59934
|
+
return await provider.getTransaction(jsonResult.transactionHash)
|
|
59935
|
+
} else {
|
|
59936
|
+
return undefined
|
|
59937
|
+
}
|
|
59938
|
+
}
|
|
59939
|
+
}
|
|
59940
|
+
|
|
59941
|
+
const isSmartContractWallet = async(blockchain, address)=>{
|
|
59942
|
+
const provider = await getProvider(blockchain);
|
|
59943
|
+
const code = await provider.getCode(address);
|
|
59944
|
+
return (code != '0x')
|
|
59945
|
+
};
|
|
59946
|
+
|
|
59947
|
+
const identifySmartContractWallet = async (blockchain, address)=>{
|
|
59948
|
+
let name;
|
|
59949
|
+
try {
|
|
59950
|
+
name = await request({
|
|
59951
|
+
blockchain,
|
|
59952
|
+
address,
|
|
59953
|
+
api: [{ "constant": true, "inputs": [], "name": "NAME", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "payable": false, "stateMutability": "view", "type": "function"}],
|
|
59954
|
+
method: 'NAME'
|
|
59955
|
+
});
|
|
59956
|
+
} catch (e) {}
|
|
59957
|
+
if(name == 'Default Callback Handler') { return 'Safe' }
|
|
59958
|
+
|
|
59959
|
+
let executor;
|
|
59960
|
+
try {
|
|
59961
|
+
executor = await request({
|
|
59962
|
+
blockchain,
|
|
59963
|
+
address,
|
|
59964
|
+
api: [{ "constant": true, "inputs": [], "name": "staticCallExecutor", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function"}],
|
|
59965
|
+
method: 'staticCallExecutor'
|
|
59966
|
+
});
|
|
59967
|
+
} catch (e2) {}
|
|
59968
|
+
if(executor) { return 'Argent' }
|
|
59969
|
+
|
|
59970
|
+
};
|
|
59971
|
+
|
|
59972
|
+
const getSmartContractWallet = async(blockchain, address)=> {
|
|
59973
|
+
if(!await isSmartContractWallet(blockchain, address)){ return }
|
|
59974
|
+
|
|
59975
|
+
const type = await identifySmartContractWallet(blockchain, address);
|
|
59976
|
+
if(type == 'Safe') {
|
|
59977
|
+
return new Safe({ blockchain, address })
|
|
59978
|
+
} else if(type == 'Argent') {
|
|
59979
|
+
return new Argent({ blockchain, address })
|
|
59980
|
+
} else {
|
|
59981
|
+
throw('Unrecognized smart contract wallet not supported!')
|
|
59982
|
+
}
|
|
59983
|
+
};
|
|
59984
|
+
|
|
59894
59985
|
const sendTransaction$3 = async ({ transaction, wallet })=> {
|
|
59895
59986
|
transaction = new Transaction$1(transaction);
|
|
59896
59987
|
if((await wallet.connectedTo(transaction.blockchain)) == false) {
|
|
@@ -59900,7 +59991,8 @@ const sendTransaction$3 = async ({ transaction, wallet })=> {
|
|
|
59900
59991
|
throw({ code: 'WRONG_NETWORK' })
|
|
59901
59992
|
}
|
|
59902
59993
|
await transaction.prepare({ wallet });
|
|
59903
|
-
|
|
59994
|
+
const smartContractWallet = await getSmartContractWallet(transaction.blockchain, transaction.from);
|
|
59995
|
+
const transactionCount = smartContractWallet ? await smartContractWallet.transactionCount() : await request({ blockchain: transaction.blockchain, method: 'transactionCount', address: transaction.from });
|
|
59904
59996
|
transaction.nonce = transactionCount;
|
|
59905
59997
|
await submit$3({ transaction, wallet }).then(async (tx)=>{
|
|
59906
59998
|
if (tx) {
|
|
@@ -59908,33 +60000,29 @@ const sendTransaction$3 = async ({ transaction, wallet })=> {
|
|
|
59908
60000
|
transaction.id = tx;
|
|
59909
60001
|
transaction.url = blockchain.explorerUrlFor({ transaction });
|
|
59910
60002
|
if (transaction.sent) transaction.sent(transaction);
|
|
59911
|
-
let sentTransaction = await retrieveTransaction$1(
|
|
60003
|
+
let sentTransaction = await retrieveTransaction$1({ blockchain: transaction.blockchain, tx, smartContractWallet });
|
|
60004
|
+
transaction.id = sentTransaction.hash || transaction.id;
|
|
60005
|
+
transaction.url = blockchain.explorerUrlFor({ transaction });
|
|
59912
60006
|
transaction.nonce = sentTransaction.nonce || transactionCount;
|
|
59913
|
-
|
|
59914
|
-
transaction.
|
|
59915
|
-
|
|
59916
|
-
|
|
59917
|
-
|
|
59918
|
-
|
|
59919
|
-
|
|
59920
|
-
|
|
59921
|
-
|
|
59922
|
-
if(error && error.
|
|
59923
|
-
|
|
59924
|
-
transaction.id = error.replacement.hash;
|
|
59925
|
-
transaction._succeeded = true;
|
|
59926
|
-
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
59927
|
-
} else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) {
|
|
59928
|
-
transaction.id = error.replacement.hash;
|
|
59929
|
-
transaction._failed = true;
|
|
59930
|
-
if(transaction.failed) transaction.failed(transaction, error);
|
|
59931
|
-
}
|
|
59932
|
-
} else {
|
|
60007
|
+
sentTransaction.wait(1).then(() => {
|
|
60008
|
+
transaction._succeeded = true;
|
|
60009
|
+
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
60010
|
+
}).catch((error)=>{
|
|
60011
|
+
if(error && error.code && error.code == 'TRANSACTION_REPLACED') {
|
|
60012
|
+
if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) {
|
|
60013
|
+
transaction.id = error.replacement.hash;
|
|
60014
|
+
transaction._succeeded = true;
|
|
60015
|
+
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
60016
|
+
} else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) {
|
|
60017
|
+
transaction.id = error.replacement.hash;
|
|
59933
60018
|
transaction._failed = true;
|
|
59934
|
-
if(transaction.failed) transaction.failed(transaction, error);
|
|
60019
|
+
if(transaction.failed) transaction.failed(transaction, error);
|
|
59935
60020
|
}
|
|
59936
|
-
}
|
|
59937
|
-
|
|
60021
|
+
} else {
|
|
60022
|
+
transaction._failed = true;
|
|
60023
|
+
if(transaction.failed) transaction.failed(transaction, error);
|
|
60024
|
+
}
|
|
60025
|
+
});
|
|
59938
60026
|
} else {
|
|
59939
60027
|
throw('Submitting transaction failed!')
|
|
59940
60028
|
}
|
|
@@ -59942,16 +60030,23 @@ const sendTransaction$3 = async ({ transaction, wallet })=> {
|
|
|
59942
60030
|
return transaction
|
|
59943
60031
|
};
|
|
59944
60032
|
|
|
59945
|
-
const retrieveTransaction$1 = async (tx,
|
|
59946
|
-
let sentTransaction;
|
|
60033
|
+
const retrieveTransaction$1 = async ({ blockchain, tx, smartContractWallet })=>{
|
|
59947
60034
|
const provider = await getProvider(blockchain);
|
|
59948
|
-
|
|
59949
|
-
|
|
59950
|
-
|
|
59951
|
-
|
|
59952
|
-
|
|
59953
|
-
|
|
59954
|
-
|
|
60035
|
+
let retrieve = async()=>{
|
|
60036
|
+
try {
|
|
60037
|
+
if(smartContractWallet && smartContractWallet.retrieveTransaction) {
|
|
60038
|
+
return await smartContractWallet.retrieveTransaction({ blockchain, tx })
|
|
60039
|
+
} else {
|
|
60040
|
+
return await provider.getTransaction(tx)
|
|
60041
|
+
}
|
|
60042
|
+
} catch (e) {}
|
|
60043
|
+
};
|
|
60044
|
+
|
|
60045
|
+
let sentTransaction;
|
|
60046
|
+
sentTransaction = await retrieve();
|
|
60047
|
+
while (!sentTransaction) {
|
|
60048
|
+
await (new Promise((resolve)=>setTimeout(resolve, 3000)));
|
|
60049
|
+
sentTransaction = await retrieve();
|
|
59955
60050
|
}
|
|
59956
60051
|
return sentTransaction
|
|
59957
60052
|
};
|
|
@@ -59971,15 +60066,6 @@ const submitContractInteraction$2 = async ({ transaction, wallet })=>{
|
|
|
59971
60066
|
const data = await transaction.getData();
|
|
59972
60067
|
const value = transaction.value ? ethers.utils.hexlify(ethers.BigNumber.from(transaction.value)) : undefined;
|
|
59973
60068
|
const nonce = ethers.utils.hexlify(transaction.nonce);
|
|
59974
|
-
console.log({
|
|
59975
|
-
from: transaction.from,
|
|
59976
|
-
to: transaction.to,
|
|
59977
|
-
value,
|
|
59978
|
-
data,
|
|
59979
|
-
gas: gas.toHexString(),
|
|
59980
|
-
gasPrice: gasPrice.toHexString(),
|
|
59981
|
-
nonce,
|
|
59982
|
-
});
|
|
59983
60069
|
return wallet.connector.sendTransaction({
|
|
59984
60070
|
from: transaction.from,
|
|
59985
60071
|
to: transaction.to,
|
|
@@ -59997,15 +60083,6 @@ const submitSimpleTransfer$3 = async ({ transaction, wallet })=>{
|
|
|
59997
60083
|
const gas = await estimate(transaction);
|
|
59998
60084
|
const value = ethers.utils.hexlify(ethers.BigNumber.from(transaction.value));
|
|
59999
60085
|
const nonce = ethers.utils.hexlify(transaction.nonce);
|
|
60000
|
-
console.log({
|
|
60001
|
-
from: transaction.from,
|
|
60002
|
-
to: transaction.to,
|
|
60003
|
-
value,
|
|
60004
|
-
data: '0x',
|
|
60005
|
-
gas: gas.toHexString(),
|
|
60006
|
-
gasPrice: gasPrice.toHexString(),
|
|
60007
|
-
nonce,
|
|
60008
|
-
});
|
|
60009
60086
|
return wallet.connector.sendTransaction({
|
|
60010
60087
|
from: transaction.from,
|
|
60011
60088
|
to: transaction.to,
|
package/dist/esm/index.js
CHANGED
|
@@ -985,6 +985,97 @@ class Trust extends WindowEthereum {
|
|
|
985
985
|
static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$3([window, 'optionalAccess', _5 => _5.ethereum, 'optionalAccess', _6 => _6.isTrust]) || _optionalChain$3([window, 'optionalAccess', _7 => _7.ethereum, 'optionalAccess', _8 => _8.isTrustWallet])) };}
|
|
986
986
|
} Trust.__initStatic(); Trust.__initStatic2();
|
|
987
987
|
|
|
988
|
+
class Argent {
|
|
989
|
+
|
|
990
|
+
constructor ({ address, blockchain }) {
|
|
991
|
+
this.address = address;
|
|
992
|
+
this.blockchain = blockchain;
|
|
993
|
+
}
|
|
994
|
+
|
|
995
|
+
async transactionCount() {
|
|
996
|
+
return 1 // irrelevant as proxy address/relayer actually sending the transaction is not known yet (but needs to be something)
|
|
997
|
+
}
|
|
998
|
+
}
|
|
999
|
+
|
|
1000
|
+
const blockchainNames = {
|
|
1001
|
+
'ethereum': 'mainnet',
|
|
1002
|
+
'bsc': 'bsc',
|
|
1003
|
+
'polygon': 'polygon',
|
|
1004
|
+
};
|
|
1005
|
+
|
|
1006
|
+
class Safe {
|
|
1007
|
+
|
|
1008
|
+
constructor ({ address, blockchain }) {
|
|
1009
|
+
this.address = address;
|
|
1010
|
+
this.blockchain = blockchain;
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
async transactionCount() {
|
|
1014
|
+
return parseInt((await request$1({
|
|
1015
|
+
blockchain: this.blockchain,
|
|
1016
|
+
address: this.address,
|
|
1017
|
+
api: [{"inputs":[],"name":"nonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}],
|
|
1018
|
+
method: 'nonce',
|
|
1019
|
+
})).toString(), 10)
|
|
1020
|
+
}
|
|
1021
|
+
|
|
1022
|
+
async retrieveTransaction({ blockchain, tx }) {
|
|
1023
|
+
const provider = await getProvider(blockchain);
|
|
1024
|
+
let jsonResult = await fetch(`https://safe-transaction-${blockchainNames[blockchain]}.safe.global/api/v1/multisig-transactions/${tx}/`)
|
|
1025
|
+
.then((response) => response.json())
|
|
1026
|
+
.catch((error) => { console.error('Error:', error); });
|
|
1027
|
+
if(jsonResult && jsonResult.isExecuted && jsonResult.transactionHash) {
|
|
1028
|
+
return await provider.getTransaction(jsonResult.transactionHash)
|
|
1029
|
+
} else {
|
|
1030
|
+
return undefined
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
const isSmartContractWallet = async(blockchain, address)=>{
|
|
1036
|
+
const provider = await getProvider(blockchain);
|
|
1037
|
+
const code = await provider.getCode(address);
|
|
1038
|
+
return (code != '0x')
|
|
1039
|
+
};
|
|
1040
|
+
|
|
1041
|
+
const identifySmartContractWallet = async (blockchain, address)=>{
|
|
1042
|
+
let name;
|
|
1043
|
+
try {
|
|
1044
|
+
name = await request$1({
|
|
1045
|
+
blockchain,
|
|
1046
|
+
address,
|
|
1047
|
+
api: [{ "constant": true, "inputs": [], "name": "NAME", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "payable": false, "stateMutability": "view", "type": "function"}],
|
|
1048
|
+
method: 'NAME'
|
|
1049
|
+
});
|
|
1050
|
+
} catch (e) {}
|
|
1051
|
+
if(name == 'Default Callback Handler') { return 'Safe' }
|
|
1052
|
+
|
|
1053
|
+
let executor;
|
|
1054
|
+
try {
|
|
1055
|
+
executor = await request$1({
|
|
1056
|
+
blockchain,
|
|
1057
|
+
address,
|
|
1058
|
+
api: [{ "constant": true, "inputs": [], "name": "staticCallExecutor", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function"}],
|
|
1059
|
+
method: 'staticCallExecutor'
|
|
1060
|
+
});
|
|
1061
|
+
} catch (e2) {}
|
|
1062
|
+
if(executor) { return 'Argent' }
|
|
1063
|
+
|
|
1064
|
+
};
|
|
1065
|
+
|
|
1066
|
+
const getSmartContractWallet = async(blockchain, address)=> {
|
|
1067
|
+
if(!await isSmartContractWallet(blockchain, address)){ return }
|
|
1068
|
+
|
|
1069
|
+
const type = await identifySmartContractWallet(blockchain, address);
|
|
1070
|
+
if(type == 'Safe') {
|
|
1071
|
+
return new Safe({ blockchain, address })
|
|
1072
|
+
} else if(type == 'Argent') {
|
|
1073
|
+
return new Argent({ blockchain, address })
|
|
1074
|
+
} else {
|
|
1075
|
+
throw('Unrecognized smart contract wallet not supported!')
|
|
1076
|
+
}
|
|
1077
|
+
};
|
|
1078
|
+
|
|
988
1079
|
const sendTransaction$2 = async ({ transaction, wallet })=> {
|
|
989
1080
|
transaction = new Transaction(transaction);
|
|
990
1081
|
if((await wallet.connectedTo(transaction.blockchain)) == false) {
|
|
@@ -994,7 +1085,8 @@ const sendTransaction$2 = async ({ transaction, wallet })=> {
|
|
|
994
1085
|
throw({ code: 'WRONG_NETWORK' })
|
|
995
1086
|
}
|
|
996
1087
|
await transaction.prepare({ wallet });
|
|
997
|
-
|
|
1088
|
+
const smartContractWallet = await getSmartContractWallet(transaction.blockchain, transaction.from);
|
|
1089
|
+
const transactionCount = smartContractWallet ? await smartContractWallet.transactionCount() : await request$1({ blockchain: transaction.blockchain, method: 'transactionCount', address: transaction.from });
|
|
998
1090
|
transaction.nonce = transactionCount;
|
|
999
1091
|
await submit$2({ transaction, wallet }).then(async (tx)=>{
|
|
1000
1092
|
if (tx) {
|
|
@@ -1002,33 +1094,29 @@ const sendTransaction$2 = async ({ transaction, wallet })=> {
|
|
|
1002
1094
|
transaction.id = tx;
|
|
1003
1095
|
transaction.url = blockchain.explorerUrlFor({ transaction });
|
|
1004
1096
|
if (transaction.sent) transaction.sent(transaction);
|
|
1005
|
-
let sentTransaction = await retrieveTransaction$1(
|
|
1097
|
+
let sentTransaction = await retrieveTransaction$1({ blockchain: transaction.blockchain, tx, smartContractWallet });
|
|
1098
|
+
transaction.id = sentTransaction.hash || transaction.id;
|
|
1099
|
+
transaction.url = blockchain.explorerUrlFor({ transaction });
|
|
1006
1100
|
transaction.nonce = sentTransaction.nonce || transactionCount;
|
|
1007
|
-
|
|
1008
|
-
transaction.
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
if(error && error.
|
|
1017
|
-
|
|
1018
|
-
transaction.id = error.replacement.hash;
|
|
1019
|
-
transaction._succeeded = true;
|
|
1020
|
-
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
1021
|
-
} else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) {
|
|
1022
|
-
transaction.id = error.replacement.hash;
|
|
1023
|
-
transaction._failed = true;
|
|
1024
|
-
if(transaction.failed) transaction.failed(transaction, error);
|
|
1025
|
-
}
|
|
1026
|
-
} else {
|
|
1101
|
+
sentTransaction.wait(1).then(() => {
|
|
1102
|
+
transaction._succeeded = true;
|
|
1103
|
+
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
1104
|
+
}).catch((error)=>{
|
|
1105
|
+
if(error && error.code && error.code == 'TRANSACTION_REPLACED') {
|
|
1106
|
+
if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) {
|
|
1107
|
+
transaction.id = error.replacement.hash;
|
|
1108
|
+
transaction._succeeded = true;
|
|
1109
|
+
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
1110
|
+
} else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) {
|
|
1111
|
+
transaction.id = error.replacement.hash;
|
|
1027
1112
|
transaction._failed = true;
|
|
1028
|
-
if(transaction.failed) transaction.failed(transaction, error);
|
|
1113
|
+
if(transaction.failed) transaction.failed(transaction, error);
|
|
1029
1114
|
}
|
|
1030
|
-
}
|
|
1031
|
-
|
|
1115
|
+
} else {
|
|
1116
|
+
transaction._failed = true;
|
|
1117
|
+
if(transaction.failed) transaction.failed(transaction, error);
|
|
1118
|
+
}
|
|
1119
|
+
});
|
|
1032
1120
|
} else {
|
|
1033
1121
|
throw('Submitting transaction failed!')
|
|
1034
1122
|
}
|
|
@@ -1036,16 +1124,23 @@ const sendTransaction$2 = async ({ transaction, wallet })=> {
|
|
|
1036
1124
|
return transaction
|
|
1037
1125
|
};
|
|
1038
1126
|
|
|
1039
|
-
const retrieveTransaction$1 = async (tx,
|
|
1040
|
-
let sentTransaction;
|
|
1127
|
+
const retrieveTransaction$1 = async ({ blockchain, tx, smartContractWallet })=>{
|
|
1041
1128
|
const provider = await getProvider(blockchain);
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1129
|
+
let retrieve = async()=>{
|
|
1130
|
+
try {
|
|
1131
|
+
if(smartContractWallet && smartContractWallet.retrieveTransaction) {
|
|
1132
|
+
return await smartContractWallet.retrieveTransaction({ blockchain, tx })
|
|
1133
|
+
} else {
|
|
1134
|
+
return await provider.getTransaction(tx)
|
|
1135
|
+
}
|
|
1136
|
+
} catch (e) {}
|
|
1137
|
+
};
|
|
1138
|
+
|
|
1139
|
+
let sentTransaction;
|
|
1140
|
+
sentTransaction = await retrieve();
|
|
1141
|
+
while (!sentTransaction) {
|
|
1142
|
+
await (new Promise((resolve)=>setTimeout(resolve, 3000)));
|
|
1143
|
+
sentTransaction = await retrieve();
|
|
1049
1144
|
}
|
|
1050
1145
|
return sentTransaction
|
|
1051
1146
|
};
|
|
@@ -1065,15 +1160,6 @@ const submitContractInteraction$2 = async ({ transaction, wallet })=>{
|
|
|
1065
1160
|
const data = await transaction.getData();
|
|
1066
1161
|
const value = transaction.value ? ethers.utils.hexlify(ethers.BigNumber.from(transaction.value)) : undefined;
|
|
1067
1162
|
const nonce = ethers.utils.hexlify(transaction.nonce);
|
|
1068
|
-
console.log({
|
|
1069
|
-
from: transaction.from,
|
|
1070
|
-
to: transaction.to,
|
|
1071
|
-
value,
|
|
1072
|
-
data,
|
|
1073
|
-
gas: gas.toHexString(),
|
|
1074
|
-
gasPrice: gasPrice.toHexString(),
|
|
1075
|
-
nonce,
|
|
1076
|
-
});
|
|
1077
1163
|
return wallet.connector.sendTransaction({
|
|
1078
1164
|
from: transaction.from,
|
|
1079
1165
|
to: transaction.to,
|
|
@@ -1091,15 +1177,6 @@ const submitSimpleTransfer$2 = async ({ transaction, wallet })=>{
|
|
|
1091
1177
|
const gas = await estimate(transaction);
|
|
1092
1178
|
const value = ethers.utils.hexlify(ethers.BigNumber.from(transaction.value));
|
|
1093
1179
|
const nonce = ethers.utils.hexlify(transaction.nonce);
|
|
1094
|
-
console.log({
|
|
1095
|
-
from: transaction.from,
|
|
1096
|
-
to: transaction.to,
|
|
1097
|
-
value,
|
|
1098
|
-
data: '0x',
|
|
1099
|
-
gas: gas.toHexString(),
|
|
1100
|
-
gasPrice: gasPrice.toHexString(),
|
|
1101
|
-
nonce,
|
|
1102
|
-
});
|
|
1103
1180
|
return wallet.connector.sendTransaction({
|
|
1104
1181
|
from: transaction.from,
|
|
1105
1182
|
to: transaction.to,
|
package/dist/umd/index.evm.js
CHANGED
|
@@ -59889,6 +59889,97 @@
|
|
|
59889
59889
|
}
|
|
59890
59890
|
};
|
|
59891
59891
|
|
|
59892
|
+
class Argent {
|
|
59893
|
+
|
|
59894
|
+
constructor ({ address, blockchain }) {
|
|
59895
|
+
this.address = address;
|
|
59896
|
+
this.blockchain = blockchain;
|
|
59897
|
+
}
|
|
59898
|
+
|
|
59899
|
+
async transactionCount() {
|
|
59900
|
+
return 1 // irrelevant as proxy address/relayer actually sending the transaction is not known yet (but needs to be something)
|
|
59901
|
+
}
|
|
59902
|
+
}
|
|
59903
|
+
|
|
59904
|
+
const blockchainNames = {
|
|
59905
|
+
'ethereum': 'mainnet',
|
|
59906
|
+
'bsc': 'bsc',
|
|
59907
|
+
'polygon': 'polygon',
|
|
59908
|
+
};
|
|
59909
|
+
|
|
59910
|
+
class Safe {
|
|
59911
|
+
|
|
59912
|
+
constructor ({ address, blockchain }) {
|
|
59913
|
+
this.address = address;
|
|
59914
|
+
this.blockchain = blockchain;
|
|
59915
|
+
}
|
|
59916
|
+
|
|
59917
|
+
async transactionCount() {
|
|
59918
|
+
return parseInt((await request({
|
|
59919
|
+
blockchain: this.blockchain,
|
|
59920
|
+
address: this.address,
|
|
59921
|
+
api: [{"inputs":[],"name":"nonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}],
|
|
59922
|
+
method: 'nonce',
|
|
59923
|
+
})).toString(), 10)
|
|
59924
|
+
}
|
|
59925
|
+
|
|
59926
|
+
async retrieveTransaction({ blockchain, tx }) {
|
|
59927
|
+
const provider = await getProvider(blockchain);
|
|
59928
|
+
let jsonResult = await fetch(`https://safe-transaction-${blockchainNames[blockchain]}.safe.global/api/v1/multisig-transactions/${tx}/`)
|
|
59929
|
+
.then((response) => response.json())
|
|
59930
|
+
.catch((error) => { console.error('Error:', error); });
|
|
59931
|
+
if(jsonResult && jsonResult.isExecuted && jsonResult.transactionHash) {
|
|
59932
|
+
return await provider.getTransaction(jsonResult.transactionHash)
|
|
59933
|
+
} else {
|
|
59934
|
+
return undefined
|
|
59935
|
+
}
|
|
59936
|
+
}
|
|
59937
|
+
}
|
|
59938
|
+
|
|
59939
|
+
const isSmartContractWallet = async(blockchain, address)=>{
|
|
59940
|
+
const provider = await getProvider(blockchain);
|
|
59941
|
+
const code = await provider.getCode(address);
|
|
59942
|
+
return (code != '0x')
|
|
59943
|
+
};
|
|
59944
|
+
|
|
59945
|
+
const identifySmartContractWallet = async (blockchain, address)=>{
|
|
59946
|
+
let name;
|
|
59947
|
+
try {
|
|
59948
|
+
name = await request({
|
|
59949
|
+
blockchain,
|
|
59950
|
+
address,
|
|
59951
|
+
api: [{ "constant": true, "inputs": [], "name": "NAME", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "payable": false, "stateMutability": "view", "type": "function"}],
|
|
59952
|
+
method: 'NAME'
|
|
59953
|
+
});
|
|
59954
|
+
} catch (e) {}
|
|
59955
|
+
if(name == 'Default Callback Handler') { return 'Safe' }
|
|
59956
|
+
|
|
59957
|
+
let executor;
|
|
59958
|
+
try {
|
|
59959
|
+
executor = await request({
|
|
59960
|
+
blockchain,
|
|
59961
|
+
address,
|
|
59962
|
+
api: [{ "constant": true, "inputs": [], "name": "staticCallExecutor", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function"}],
|
|
59963
|
+
method: 'staticCallExecutor'
|
|
59964
|
+
});
|
|
59965
|
+
} catch (e2) {}
|
|
59966
|
+
if(executor) { return 'Argent' }
|
|
59967
|
+
|
|
59968
|
+
};
|
|
59969
|
+
|
|
59970
|
+
const getSmartContractWallet = async(blockchain, address)=> {
|
|
59971
|
+
if(!await isSmartContractWallet(blockchain, address)){ return }
|
|
59972
|
+
|
|
59973
|
+
const type = await identifySmartContractWallet(blockchain, address);
|
|
59974
|
+
if(type == 'Safe') {
|
|
59975
|
+
return new Safe({ blockchain, address })
|
|
59976
|
+
} else if(type == 'Argent') {
|
|
59977
|
+
return new Argent({ blockchain, address })
|
|
59978
|
+
} else {
|
|
59979
|
+
throw('Unrecognized smart contract wallet not supported!')
|
|
59980
|
+
}
|
|
59981
|
+
};
|
|
59982
|
+
|
|
59892
59983
|
const sendTransaction$3 = async ({ transaction, wallet })=> {
|
|
59893
59984
|
transaction = new Transaction$1(transaction);
|
|
59894
59985
|
if((await wallet.connectedTo(transaction.blockchain)) == false) {
|
|
@@ -59898,7 +59989,8 @@
|
|
|
59898
59989
|
throw({ code: 'WRONG_NETWORK' })
|
|
59899
59990
|
}
|
|
59900
59991
|
await transaction.prepare({ wallet });
|
|
59901
|
-
|
|
59992
|
+
const smartContractWallet = await getSmartContractWallet(transaction.blockchain, transaction.from);
|
|
59993
|
+
const transactionCount = smartContractWallet ? await smartContractWallet.transactionCount() : await request({ blockchain: transaction.blockchain, method: 'transactionCount', address: transaction.from });
|
|
59902
59994
|
transaction.nonce = transactionCount;
|
|
59903
59995
|
await submit$3({ transaction, wallet }).then(async (tx)=>{
|
|
59904
59996
|
if (tx) {
|
|
@@ -59906,33 +59998,29 @@
|
|
|
59906
59998
|
transaction.id = tx;
|
|
59907
59999
|
transaction.url = blockchain.explorerUrlFor({ transaction });
|
|
59908
60000
|
if (transaction.sent) transaction.sent(transaction);
|
|
59909
|
-
let sentTransaction = await retrieveTransaction$1(
|
|
60001
|
+
let sentTransaction = await retrieveTransaction$1({ blockchain: transaction.blockchain, tx, smartContractWallet });
|
|
60002
|
+
transaction.id = sentTransaction.hash || transaction.id;
|
|
60003
|
+
transaction.url = blockchain.explorerUrlFor({ transaction });
|
|
59910
60004
|
transaction.nonce = sentTransaction.nonce || transactionCount;
|
|
59911
|
-
|
|
59912
|
-
transaction.
|
|
59913
|
-
|
|
59914
|
-
|
|
59915
|
-
|
|
59916
|
-
|
|
59917
|
-
|
|
59918
|
-
|
|
59919
|
-
|
|
59920
|
-
if(error && error.
|
|
59921
|
-
|
|
59922
|
-
transaction.id = error.replacement.hash;
|
|
59923
|
-
transaction._succeeded = true;
|
|
59924
|
-
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
59925
|
-
} else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) {
|
|
59926
|
-
transaction.id = error.replacement.hash;
|
|
59927
|
-
transaction._failed = true;
|
|
59928
|
-
if(transaction.failed) transaction.failed(transaction, error);
|
|
59929
|
-
}
|
|
59930
|
-
} else {
|
|
60005
|
+
sentTransaction.wait(1).then(() => {
|
|
60006
|
+
transaction._succeeded = true;
|
|
60007
|
+
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
60008
|
+
}).catch((error)=>{
|
|
60009
|
+
if(error && error.code && error.code == 'TRANSACTION_REPLACED') {
|
|
60010
|
+
if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) {
|
|
60011
|
+
transaction.id = error.replacement.hash;
|
|
60012
|
+
transaction._succeeded = true;
|
|
60013
|
+
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
60014
|
+
} else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) {
|
|
60015
|
+
transaction.id = error.replacement.hash;
|
|
59931
60016
|
transaction._failed = true;
|
|
59932
|
-
if(transaction.failed) transaction.failed(transaction, error);
|
|
60017
|
+
if(transaction.failed) transaction.failed(transaction, error);
|
|
59933
60018
|
}
|
|
59934
|
-
}
|
|
59935
|
-
|
|
60019
|
+
} else {
|
|
60020
|
+
transaction._failed = true;
|
|
60021
|
+
if(transaction.failed) transaction.failed(transaction, error);
|
|
60022
|
+
}
|
|
60023
|
+
});
|
|
59936
60024
|
} else {
|
|
59937
60025
|
throw('Submitting transaction failed!')
|
|
59938
60026
|
}
|
|
@@ -59940,16 +60028,23 @@
|
|
|
59940
60028
|
return transaction
|
|
59941
60029
|
};
|
|
59942
60030
|
|
|
59943
|
-
const retrieveTransaction$1 = async (tx,
|
|
59944
|
-
let sentTransaction;
|
|
60031
|
+
const retrieveTransaction$1 = async ({ blockchain, tx, smartContractWallet })=>{
|
|
59945
60032
|
const provider = await getProvider(blockchain);
|
|
59946
|
-
|
|
59947
|
-
|
|
59948
|
-
|
|
59949
|
-
|
|
59950
|
-
|
|
59951
|
-
|
|
59952
|
-
|
|
60033
|
+
let retrieve = async()=>{
|
|
60034
|
+
try {
|
|
60035
|
+
if(smartContractWallet && smartContractWallet.retrieveTransaction) {
|
|
60036
|
+
return await smartContractWallet.retrieveTransaction({ blockchain, tx })
|
|
60037
|
+
} else {
|
|
60038
|
+
return await provider.getTransaction(tx)
|
|
60039
|
+
}
|
|
60040
|
+
} catch (e) {}
|
|
60041
|
+
};
|
|
60042
|
+
|
|
60043
|
+
let sentTransaction;
|
|
60044
|
+
sentTransaction = await retrieve();
|
|
60045
|
+
while (!sentTransaction) {
|
|
60046
|
+
await (new Promise((resolve)=>setTimeout(resolve, 3000)));
|
|
60047
|
+
sentTransaction = await retrieve();
|
|
59953
60048
|
}
|
|
59954
60049
|
return sentTransaction
|
|
59955
60050
|
};
|
|
@@ -59969,15 +60064,6 @@
|
|
|
59969
60064
|
const data = await transaction.getData();
|
|
59970
60065
|
const value = transaction.value ? ethers.ethers.utils.hexlify(ethers.ethers.BigNumber.from(transaction.value)) : undefined;
|
|
59971
60066
|
const nonce = ethers.ethers.utils.hexlify(transaction.nonce);
|
|
59972
|
-
console.log({
|
|
59973
|
-
from: transaction.from,
|
|
59974
|
-
to: transaction.to,
|
|
59975
|
-
value,
|
|
59976
|
-
data,
|
|
59977
|
-
gas: gas.toHexString(),
|
|
59978
|
-
gasPrice: gasPrice.toHexString(),
|
|
59979
|
-
nonce,
|
|
59980
|
-
});
|
|
59981
60067
|
return wallet.connector.sendTransaction({
|
|
59982
60068
|
from: transaction.from,
|
|
59983
60069
|
to: transaction.to,
|
|
@@ -59995,15 +60081,6 @@
|
|
|
59995
60081
|
const gas = await estimate(transaction);
|
|
59996
60082
|
const value = ethers.ethers.utils.hexlify(ethers.ethers.BigNumber.from(transaction.value));
|
|
59997
60083
|
const nonce = ethers.ethers.utils.hexlify(transaction.nonce);
|
|
59998
|
-
console.log({
|
|
59999
|
-
from: transaction.from,
|
|
60000
|
-
to: transaction.to,
|
|
60001
|
-
value,
|
|
60002
|
-
data: '0x',
|
|
60003
|
-
gas: gas.toHexString(),
|
|
60004
|
-
gasPrice: gasPrice.toHexString(),
|
|
60005
|
-
nonce,
|
|
60006
|
-
});
|
|
60007
60084
|
return wallet.connector.sendTransaction({
|
|
60008
60085
|
from: transaction.from,
|
|
60009
60086
|
to: transaction.to,
|
package/dist/umd/index.js
CHANGED
|
@@ -982,6 +982,97 @@
|
|
|
982
982
|
static __initStatic2() {this.isAvailable = ()=>{ return (_optionalChain$3([window, 'optionalAccess', _5 => _5.ethereum, 'optionalAccess', _6 => _6.isTrust]) || _optionalChain$3([window, 'optionalAccess', _7 => _7.ethereum, 'optionalAccess', _8 => _8.isTrustWallet])) };}
|
|
983
983
|
} Trust.__initStatic(); Trust.__initStatic2();
|
|
984
984
|
|
|
985
|
+
class Argent {
|
|
986
|
+
|
|
987
|
+
constructor ({ address, blockchain }) {
|
|
988
|
+
this.address = address;
|
|
989
|
+
this.blockchain = blockchain;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
async transactionCount() {
|
|
993
|
+
return 1 // irrelevant as proxy address/relayer actually sending the transaction is not known yet (but needs to be something)
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
|
|
997
|
+
const blockchainNames = {
|
|
998
|
+
'ethereum': 'mainnet',
|
|
999
|
+
'bsc': 'bsc',
|
|
1000
|
+
'polygon': 'polygon',
|
|
1001
|
+
};
|
|
1002
|
+
|
|
1003
|
+
class Safe {
|
|
1004
|
+
|
|
1005
|
+
constructor ({ address, blockchain }) {
|
|
1006
|
+
this.address = address;
|
|
1007
|
+
this.blockchain = blockchain;
|
|
1008
|
+
}
|
|
1009
|
+
|
|
1010
|
+
async transactionCount() {
|
|
1011
|
+
return parseInt((await web3Client.request({
|
|
1012
|
+
blockchain: this.blockchain,
|
|
1013
|
+
address: this.address,
|
|
1014
|
+
api: [{"inputs":[],"name":"nonce","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"}],
|
|
1015
|
+
method: 'nonce',
|
|
1016
|
+
})).toString(), 10)
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
async retrieveTransaction({ blockchain, tx }) {
|
|
1020
|
+
const provider = await web3Client.getProvider(blockchain);
|
|
1021
|
+
let jsonResult = await fetch(`https://safe-transaction-${blockchainNames[blockchain]}.safe.global/api/v1/multisig-transactions/${tx}/`)
|
|
1022
|
+
.then((response) => response.json())
|
|
1023
|
+
.catch((error) => { console.error('Error:', error); });
|
|
1024
|
+
if(jsonResult && jsonResult.isExecuted && jsonResult.transactionHash) {
|
|
1025
|
+
return await provider.getTransaction(jsonResult.transactionHash)
|
|
1026
|
+
} else {
|
|
1027
|
+
return undefined
|
|
1028
|
+
}
|
|
1029
|
+
}
|
|
1030
|
+
}
|
|
1031
|
+
|
|
1032
|
+
const isSmartContractWallet = async(blockchain, address)=>{
|
|
1033
|
+
const provider = await web3Client.getProvider(blockchain);
|
|
1034
|
+
const code = await provider.getCode(address);
|
|
1035
|
+
return (code != '0x')
|
|
1036
|
+
};
|
|
1037
|
+
|
|
1038
|
+
const identifySmartContractWallet = async (blockchain, address)=>{
|
|
1039
|
+
let name;
|
|
1040
|
+
try {
|
|
1041
|
+
name = await web3Client.request({
|
|
1042
|
+
blockchain,
|
|
1043
|
+
address,
|
|
1044
|
+
api: [{ "constant": true, "inputs": [], "name": "NAME", "outputs": [{ "internalType": "string", "name": "", "type": "string" }], "payable": false, "stateMutability": "view", "type": "function"}],
|
|
1045
|
+
method: 'NAME'
|
|
1046
|
+
});
|
|
1047
|
+
} catch (e) {}
|
|
1048
|
+
if(name == 'Default Callback Handler') { return 'Safe' }
|
|
1049
|
+
|
|
1050
|
+
let executor;
|
|
1051
|
+
try {
|
|
1052
|
+
executor = await web3Client.request({
|
|
1053
|
+
blockchain,
|
|
1054
|
+
address,
|
|
1055
|
+
api: [{ "constant": true, "inputs": [], "name": "staticCallExecutor", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function"}],
|
|
1056
|
+
method: 'staticCallExecutor'
|
|
1057
|
+
});
|
|
1058
|
+
} catch (e2) {}
|
|
1059
|
+
if(executor) { return 'Argent' }
|
|
1060
|
+
|
|
1061
|
+
};
|
|
1062
|
+
|
|
1063
|
+
const getSmartContractWallet = async(blockchain, address)=> {
|
|
1064
|
+
if(!await isSmartContractWallet(blockchain, address)){ return }
|
|
1065
|
+
|
|
1066
|
+
const type = await identifySmartContractWallet(blockchain, address);
|
|
1067
|
+
if(type == 'Safe') {
|
|
1068
|
+
return new Safe({ blockchain, address })
|
|
1069
|
+
} else if(type == 'Argent') {
|
|
1070
|
+
return new Argent({ blockchain, address })
|
|
1071
|
+
} else {
|
|
1072
|
+
throw('Unrecognized smart contract wallet not supported!')
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
|
|
985
1076
|
const sendTransaction$2 = async ({ transaction, wallet })=> {
|
|
986
1077
|
transaction = new Transaction(transaction);
|
|
987
1078
|
if((await wallet.connectedTo(transaction.blockchain)) == false) {
|
|
@@ -991,7 +1082,8 @@
|
|
|
991
1082
|
throw({ code: 'WRONG_NETWORK' })
|
|
992
1083
|
}
|
|
993
1084
|
await transaction.prepare({ wallet });
|
|
994
|
-
|
|
1085
|
+
const smartContractWallet = await getSmartContractWallet(transaction.blockchain, transaction.from);
|
|
1086
|
+
const transactionCount = smartContractWallet ? await smartContractWallet.transactionCount() : await web3Client.request({ blockchain: transaction.blockchain, method: 'transactionCount', address: transaction.from });
|
|
995
1087
|
transaction.nonce = transactionCount;
|
|
996
1088
|
await submit$2({ transaction, wallet }).then(async (tx)=>{
|
|
997
1089
|
if (tx) {
|
|
@@ -999,33 +1091,29 @@
|
|
|
999
1091
|
transaction.id = tx;
|
|
1000
1092
|
transaction.url = blockchain.explorerUrlFor({ transaction });
|
|
1001
1093
|
if (transaction.sent) transaction.sent(transaction);
|
|
1002
|
-
let sentTransaction = await retrieveTransaction$1(
|
|
1094
|
+
let sentTransaction = await retrieveTransaction$1({ blockchain: transaction.blockchain, tx, smartContractWallet });
|
|
1095
|
+
transaction.id = sentTransaction.hash || transaction.id;
|
|
1096
|
+
transaction.url = blockchain.explorerUrlFor({ transaction });
|
|
1003
1097
|
transaction.nonce = sentTransaction.nonce || transactionCount;
|
|
1004
|
-
|
|
1005
|
-
transaction.
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
if(error && error.
|
|
1014
|
-
|
|
1015
|
-
transaction.id = error.replacement.hash;
|
|
1016
|
-
transaction._succeeded = true;
|
|
1017
|
-
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
1018
|
-
} else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) {
|
|
1019
|
-
transaction.id = error.replacement.hash;
|
|
1020
|
-
transaction._failed = true;
|
|
1021
|
-
if(transaction.failed) transaction.failed(transaction, error);
|
|
1022
|
-
}
|
|
1023
|
-
} else {
|
|
1098
|
+
sentTransaction.wait(1).then(() => {
|
|
1099
|
+
transaction._succeeded = true;
|
|
1100
|
+
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
1101
|
+
}).catch((error)=>{
|
|
1102
|
+
if(error && error.code && error.code == 'TRANSACTION_REPLACED') {
|
|
1103
|
+
if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 1) {
|
|
1104
|
+
transaction.id = error.replacement.hash;
|
|
1105
|
+
transaction._succeeded = true;
|
|
1106
|
+
if (transaction.succeeded) transaction.succeeded(transaction);
|
|
1107
|
+
} else if(error.replacement && error.replacement.hash && error.receipt && error.receipt.status == 0) {
|
|
1108
|
+
transaction.id = error.replacement.hash;
|
|
1024
1109
|
transaction._failed = true;
|
|
1025
|
-
if(transaction.failed) transaction.failed(transaction, error);
|
|
1110
|
+
if(transaction.failed) transaction.failed(transaction, error);
|
|
1026
1111
|
}
|
|
1027
|
-
}
|
|
1028
|
-
|
|
1112
|
+
} else {
|
|
1113
|
+
transaction._failed = true;
|
|
1114
|
+
if(transaction.failed) transaction.failed(transaction, error);
|
|
1115
|
+
}
|
|
1116
|
+
});
|
|
1029
1117
|
} else {
|
|
1030
1118
|
throw('Submitting transaction failed!')
|
|
1031
1119
|
}
|
|
@@ -1033,16 +1121,23 @@
|
|
|
1033
1121
|
return transaction
|
|
1034
1122
|
};
|
|
1035
1123
|
|
|
1036
|
-
const retrieveTransaction$1 = async (tx,
|
|
1037
|
-
let sentTransaction;
|
|
1124
|
+
const retrieveTransaction$1 = async ({ blockchain, tx, smartContractWallet })=>{
|
|
1038
1125
|
const provider = await web3Client.getProvider(blockchain);
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1126
|
+
let retrieve = async()=>{
|
|
1127
|
+
try {
|
|
1128
|
+
if(smartContractWallet && smartContractWallet.retrieveTransaction) {
|
|
1129
|
+
return await smartContractWallet.retrieveTransaction({ blockchain, tx })
|
|
1130
|
+
} else {
|
|
1131
|
+
return await provider.getTransaction(tx)
|
|
1132
|
+
}
|
|
1133
|
+
} catch (e) {}
|
|
1134
|
+
};
|
|
1135
|
+
|
|
1136
|
+
let sentTransaction;
|
|
1137
|
+
sentTransaction = await retrieve();
|
|
1138
|
+
while (!sentTransaction) {
|
|
1139
|
+
await (new Promise((resolve)=>setTimeout(resolve, 3000)));
|
|
1140
|
+
sentTransaction = await retrieve();
|
|
1046
1141
|
}
|
|
1047
1142
|
return sentTransaction
|
|
1048
1143
|
};
|
|
@@ -1062,15 +1157,6 @@
|
|
|
1062
1157
|
const data = await transaction.getData();
|
|
1063
1158
|
const value = transaction.value ? ethers.ethers.utils.hexlify(ethers.ethers.BigNumber.from(transaction.value)) : undefined;
|
|
1064
1159
|
const nonce = ethers.ethers.utils.hexlify(transaction.nonce);
|
|
1065
|
-
console.log({
|
|
1066
|
-
from: transaction.from,
|
|
1067
|
-
to: transaction.to,
|
|
1068
|
-
value,
|
|
1069
|
-
data,
|
|
1070
|
-
gas: gas.toHexString(),
|
|
1071
|
-
gasPrice: gasPrice.toHexString(),
|
|
1072
|
-
nonce,
|
|
1073
|
-
});
|
|
1074
1160
|
return wallet.connector.sendTransaction({
|
|
1075
1161
|
from: transaction.from,
|
|
1076
1162
|
to: transaction.to,
|
|
@@ -1088,15 +1174,6 @@
|
|
|
1088
1174
|
const gas = await web3Client.estimate(transaction);
|
|
1089
1175
|
const value = ethers.ethers.utils.hexlify(ethers.ethers.BigNumber.from(transaction.value));
|
|
1090
1176
|
const nonce = ethers.ethers.utils.hexlify(transaction.nonce);
|
|
1091
|
-
console.log({
|
|
1092
|
-
from: transaction.from,
|
|
1093
|
-
to: transaction.to,
|
|
1094
|
-
value,
|
|
1095
|
-
data: '0x',
|
|
1096
|
-
gas: gas.toHexString(),
|
|
1097
|
-
gasPrice: gasPrice.toHexString(),
|
|
1098
|
-
nonce,
|
|
1099
|
-
});
|
|
1100
1177
|
return wallet.connector.sendTransaction({
|
|
1101
1178
|
from: transaction.from,
|
|
1102
1179
|
to: transaction.to,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depay/web3-wallets-evm",
|
|
3
3
|
"moduleName": "Web3Wallets",
|
|
4
|
-
"version": "14.
|
|
4
|
+
"version": "14.6.1",
|
|
5
5
|
"description": "One-Stop-Shop JavaScript library to integrate various web3 crypto wallets and multiple blockchains at once with a single interface.",
|
|
6
6
|
"main": "dist/umd/index.evm.js",
|
|
7
7
|
"module": "dist/esm/index.evm.js",
|