-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: prepare sway scripts for mainnet (#280)
Co-authored-by: K1-R1 <77465250+K1-R1@users.noreply.github.com> Co-authored-by: Luiz Estácio | stacio.eth <luizstacio@gmail.com> Co-authored-by: Viraz Malhotra <virajm72@gmail.com>
- Loading branch information
1 parent
2f61bd8
commit 5ddd191
Showing
17 changed files
with
1,950 additions
and
42 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
'@fuel-bridge/test-utils': minor | ||
--- | ||
|
||
Improve sway scripts |
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
/** | ||
* This is a stand-alone script that looks an address' balances | ||
*/ | ||
|
||
import { password } from '@inquirer/prompts'; | ||
import { Provider, WalletUnlocked } from 'fuels'; | ||
|
||
let { L2_ADDRESS, L2_RPC } = process.env; | ||
|
||
const main = async () => { | ||
const provider = await Provider.create(L2_RPC, { resourceCacheTTL: -1 }); | ||
|
||
if (!L2_ADDRESS) { | ||
const privKey = await password({ message: 'Enter private key' }); | ||
const wallet = new WalletUnlocked(privKey); | ||
L2_ADDRESS = wallet.address.toB256(); | ||
} | ||
|
||
await provider.getBalances(L2_ADDRESS).then(console.log); | ||
}; | ||
|
||
main() | ||
.then(() => { | ||
console.log('\t> Finished'); | ||
process.exit(0); | ||
}) | ||
.catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/** | ||
* This is a stand-alone script that looks for a message nonce | ||
*/ | ||
|
||
import { BN, Message, Provider } from 'fuels'; | ||
|
||
let { L2_RPC, L2_MESSAGE_NONCE } = process.env; | ||
|
||
const main = async () => { | ||
if (!L2_MESSAGE_NONCE) { | ||
console.log('Specify L2_MESSAGE_NONCE'); | ||
return; | ||
} | ||
|
||
if (!L2_RPC) { | ||
console.log('Specify L2_RPC'); | ||
return; | ||
} | ||
|
||
const provider = await Provider.create(L2_RPC, { resourceCacheTTL: -1 }); | ||
|
||
const message: Message = await provider | ||
.getMessageByNonce(new BN(L2_MESSAGE_NONCE).toHex(32)) | ||
.catch((e) => { | ||
console.log(JSON.stringify(e, undefined, 2)); | ||
return null; | ||
}); | ||
|
||
if (!message) { | ||
console.log('Could not fetch message'); | ||
} | ||
|
||
console.log(message); | ||
}; | ||
|
||
main() | ||
.then(() => { | ||
console.log('\t> Finished'); | ||
process.exit(0); | ||
}) | ||
.catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/** | ||
* This is a stand-alone script that | ||
* calls the bridge 's withdraw method | ||
*/ | ||
|
||
import { Proxy } from '@fuel-bridge/fungible-token'; | ||
|
||
import { Provider } from 'fuels'; | ||
|
||
let { L2_RPC, L2_BRIDGE_ID } = process.env; | ||
const L1_LLAMA_RPC = 'https://eth.llamarpc.com'; | ||
const main = async () => { | ||
const fuel_provider = await Provider.create(L2_RPC, { resourceCacheTTL: -1 }); | ||
|
||
const proxy = new Proxy(L2_BRIDGE_ID, fuel_provider); | ||
|
||
console.log('\t> Checking asset metadata...'); | ||
|
||
console.log('Owner', (await proxy.functions._proxy_owner().get()).value); | ||
console.log('Target', (await proxy.functions.proxy_target().get()).value); | ||
}; | ||
|
||
main() | ||
.then(() => { | ||
console.log('\t> Finished'); | ||
process.exit(0); | ||
}) | ||
.catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |
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 |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/** | ||
* This is a stand-alone script that self-transfers | ||
* to convert a message coin into a coin utxo | ||
*/ | ||
|
||
import { Provider, TransactionStatus, Wallet } from 'fuels'; | ||
import { password } from '@inquirer/prompts'; | ||
|
||
let { L2_SIGNER, L2_RPC } = process.env; | ||
|
||
const main = async () => { | ||
if (!L2_RPC) { | ||
console.log('Must provide L2_RPC'); | ||
return; | ||
} | ||
|
||
const provider = await Provider.create(L2_RPC, { resourceCacheTTL: -1 }); | ||
|
||
if (!L2_SIGNER) { | ||
L2_SIGNER = await password({ message: 'Enter private key' }); | ||
} | ||
|
||
const wallet = Wallet.fromPrivateKey(L2_SIGNER, provider); | ||
const balance = await wallet.getBalance(); | ||
const tx = await wallet.transfer(wallet.address, balance.div(2)); | ||
|
||
console.log('\tTransaction ID: ', tx.id); | ||
const txResult = await tx.waitForResult(); | ||
|
||
if (txResult.status === TransactionStatus.success) { | ||
console.log('\t> Transaction succeeded'); | ||
} else { | ||
console.log('\t> Transaction errored'); | ||
} | ||
}; | ||
|
||
main() | ||
.then(() => { | ||
console.log('\t> Finished'); | ||
process.exit(0); | ||
}) | ||
.catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |
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.