-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: small fixes for WalletConnect alpha.32 (#7507)
### Description There has been a few breaking changes as part of the WalletConnect alpha tumult. ### Other changes Added the scripts `run-in-memory-client` and `run-in-memory-wallet` as the most bare bones sanity test you can run. You run the client, copy the URL and then run the wallet. Also nice for testing automated flows, - I can run a wallet (Valora) and then startup a client that automatically does a bunch of operations - I can run a client (https://use-contractkit.vercel.app) and then run a wallet that automatically approves operations ### Tested ``` cd packages/sdk/wallets/wallet-walletconnect WALLET_CONNECT_BRIGDE=wss://relay.walletconnect.org yarn test WALLET_CONNECT_BRIGDE=wss://walletconnect.celo-networks-dev.org yarn test ```
- Loading branch information
Alex
authored
Mar 25, 2021
1 parent
eec6357
commit fe6e010
Showing
11 changed files
with
154 additions
and
68 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
56 changes: 56 additions & 0 deletions
56
packages/sdk/wallets/wallet-walletconnect/scripts/run-in-memory-client.ts
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,56 @@ | ||
import { newKit } from '@celo/contractkit' | ||
import { WalletConnectWallet } from '../src' | ||
|
||
async function main() { | ||
const wallet = new WalletConnectWallet({ | ||
connect: { | ||
metadata: { | ||
name: 'use-contractkit demo', | ||
description: 'A showcase of use-contractkit', | ||
url: 'https://use-contractkit.vercel.app', | ||
icons: [], | ||
}, | ||
}, | ||
init: { | ||
relayProvider: 'wss://relay.walletconnect.org', | ||
logger: 'error', | ||
}, | ||
}) | ||
const uri = await wallet.getUri() | ||
console.log(`=== START OUT OF BAND URI === | ||
${uri.toString()} | ||
=== END OUT OF BAND URI ===`) | ||
await wallet.init() | ||
|
||
const [from] = await wallet.getAccounts() | ||
const kit = newKit('https://alfajores-forno.celo-testnet.org', wallet) | ||
|
||
/** | ||
* Uncomment to send a test transaction | ||
*/ | ||
// const gold = await kit.contracts.getGoldToken() | ||
// await gold | ||
// .transfer('0x4132F04EaCfdE9E2b707667A13CB69DbC5BABb68', '1') | ||
// .sendAndWaitForReceipt({ from }) | ||
// console.log('Transaction sent!') | ||
|
||
/** | ||
* Uncomment to sign a test payload | ||
*/ | ||
// await kit.connection.sign(ensureLeading0x(Buffer.from('hello').toString()), from) | ||
// console.log('Payload signed!') | ||
|
||
/** | ||
* Uncomment to hold connection open | ||
*/ | ||
// await new Promise((resolve) => setTimeout(resolve, 1000 * 60 * 60 * 24)) | ||
|
||
await wallet.close() | ||
} | ||
|
||
main() | ||
.then(() => process.exit()) | ||
.catch((e) => { | ||
console.error(e) | ||
process.exit(1) | ||
}) |
10 changes: 10 additions & 0 deletions
10
packages/sdk/wallets/wallet-walletconnect/scripts/run-in-memory-wallet.ts
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,10 @@ | ||
import { getTestWallet } from '../src/test/in-memory-wallet' | ||
;(async function main() { | ||
const uri = process.argv[2] | ||
if (!uri) { | ||
return | ||
} | ||
|
||
const wallet = getTestWallet() | ||
await wallet.init(uri) | ||
})() |
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
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