-
Notifications
You must be signed in to change notification settings - Fork 88
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
72 changed files
with
486 additions
and
656 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 2 additions & 14 deletions
16
...tests__/utils/blockchain/starknet.spec.js → src/__tests__/utils/starknet.spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,80 +1,69 @@ | ||
import utils from '../utils'; | ||
import { | ||
sendL1Transaction, | ||
callL1Contract, | ||
sendL2Transaction, | ||
parseFromDecimals, | ||
parseToDecimals, | ||
parseToFelt, | ||
parseToUint256 | ||
} from '../utils'; | ||
|
||
export const deposit = async ({recipient, amount, decimals, contract, options, emitter}) => { | ||
try { | ||
return utils.blockchain.ethereum.sendTransaction( | ||
contract, | ||
'deposit', | ||
[utils.parser.parseToDecimals(amount, decimals), recipient], | ||
options, | ||
emitter | ||
); | ||
} catch (ex) { | ||
return Promise.reject(ex); | ||
} | ||
return sendL1Transaction( | ||
contract, | ||
'deposit', | ||
[parseToDecimals(amount, decimals), recipient], | ||
options, | ||
emitter | ||
); | ||
}; | ||
|
||
export const depositEth = async ({recipient, amount, contract, options, emitter}) => { | ||
try { | ||
return utils.blockchain.ethereum.sendTransaction( | ||
contract, | ||
'deposit', | ||
[recipient], | ||
{ | ||
...options, | ||
value: utils.parser.parseToDecimals(amount) | ||
}, | ||
emitter | ||
); | ||
} catch (ex) { | ||
return Promise.reject(ex); | ||
} | ||
return sendL1Transaction( | ||
contract, | ||
'deposit', | ||
[recipient], | ||
{ | ||
...options, | ||
value: parseToDecimals(amount) | ||
}, | ||
emitter | ||
); | ||
}; | ||
|
||
export const withdraw = async ({recipient, amount, decimals, contract, emitter}) => { | ||
try { | ||
return utils.blockchain.ethereum.sendTransaction( | ||
contract, | ||
'withdraw', | ||
[utils.parser.parseToDecimals(amount, decimals), recipient], | ||
{ | ||
from: recipient | ||
}, | ||
emitter | ||
); | ||
} catch (ex) { | ||
return Promise.reject(ex); | ||
} | ||
return sendL1Transaction( | ||
contract, | ||
'withdraw', | ||
[parseToDecimals(amount, decimals), recipient], | ||
{ | ||
from: recipient | ||
}, | ||
emitter | ||
); | ||
}; | ||
|
||
export const maxDeposit = async ({decimals, contract}) => { | ||
try { | ||
const maxDeposit = await utils.blockchain.ethereum.callContract(contract, 'maxDeposit'); | ||
return utils.parser.parseFromDecimals(maxDeposit, decimals); | ||
const maxDeposit = await callL1Contract(contract, 'maxDeposit'); | ||
return parseFromDecimals(maxDeposit, decimals); | ||
} catch (ex) { | ||
return Promise.reject(ex); | ||
} | ||
}; | ||
|
||
export const maxTotalBalance = async ({decimals, contract}) => { | ||
try { | ||
const maxTotalBalance = await utils.blockchain.ethereum.callContract( | ||
contract, | ||
'maxTotalBalance' | ||
); | ||
return utils.parser.parseFromDecimals(maxTotalBalance, decimals); | ||
const maxTotalBalance = await callL1Contract(contract, 'maxTotalBalance'); | ||
return parseFromDecimals(maxTotalBalance, decimals); | ||
} catch (ex) { | ||
return Promise.reject(ex); | ||
} | ||
}; | ||
|
||
export const initiateWithdraw = async ({recipient, amount, decimals, contract}) => { | ||
try { | ||
return utils.blockchain.starknet.sendTransaction(contract, 'initiate_withdraw', { | ||
l1Recipient: utils.parser.parseToFelt(recipient), | ||
amount: utils.parser.parseToUint256(amount, decimals) | ||
}); | ||
} catch (ex) { | ||
return Promise.reject(ex); | ||
} | ||
return sendL2Transaction(contract, 'initiate_withdraw', { | ||
l1Recipient: parseToFelt(recipient), | ||
amount: parseToUint256(amount, decimals) | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.