forked from thorswap/SwapKit
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: better formatters and new toSignificant (thorswap#365)
* chore: better formatters and new toSignificant * chore: add more big int tests * fix: assetValue, node env playground & comsos connections
- Loading branch information
1 parent
645e7d9
commit 4ad62d8
Showing
31 changed files
with
800 additions
and
648 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,21 @@ | ||
--- | ||
'@swapkit/wallet-evm-extensions': patch | ||
'@swapkit/toolbox-cosmos': patch | ||
'@swapkit/wallet-keystore': patch | ||
'@swapkit/helpers': patch | ||
'@swapkit/tokens': patch | ||
'@swapkit/toolbox-utxo': patch | ||
'@swapkit/wallet-ledger': patch | ||
'@swapkit/wallet-trezor': patch | ||
'@swapkit/types': patch | ||
'@swapkit/toolbox-evm': patch | ||
'@swapkit/wallet-keplr': patch | ||
'@swapkit/wallet-xdefi': patch | ||
'@swapkit/core': patch | ||
'@swapkit/api': patch | ||
'@swapkit/sdk': patch | ||
'@swapkit/wallet-okx': patch | ||
'@swapkit/wallet-wc': patch | ||
--- | ||
|
||
fix rpc connection |
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 @@ | ||
--- | ||
'@swapkit/tokens': patch | ||
--- | ||
|
||
add kuji.usk |
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,75 @@ | ||
import { AssetValue, Chain, SwapKitCore } from '@swapkit/core'; | ||
import { keystoreWallet } from '@swapkit/wallet-keystore'; | ||
let skClient: SwapKitCore | undefined; | ||
const phrase = process.env.PRHASES; | ||
|
||
if (!phrase) throw new Error('No phrase found'); | ||
|
||
const getSwapKitClient = async () => { | ||
try { | ||
if (skClient) return skClient; | ||
const client = new SwapKitCore(); | ||
client.extend({ wallets: [keystoreWallet] }); | ||
|
||
await client.connectKeystore([Chain.THORChain], phrase); | ||
skClient = client; | ||
return client; | ||
} catch (error) { | ||
console.error(error); | ||
throw new Error('Error getting SwapKit client'); | ||
} | ||
}; | ||
/** | ||
* send an asset from your wallet to another address | ||
*/ | ||
export const doSend = async ({ | ||
sendAmount, | ||
toAddress, | ||
}: { | ||
sendAmount: number; | ||
toAddress: string; | ||
}) => { | ||
try { | ||
const client = await getSwapKitClient(); | ||
const from = client.getAddress(Chain.THORChain); | ||
const balance = await client.getBalance(Chain.THORChain); | ||
console.log(`Balance: ${balance}`); | ||
console.log(`💰 Wallet - ${from} | Balance: ${balance}}`); | ||
|
||
const assetValue = await AssetValue.fromString('THOR.RUNE', sendAmount); | ||
console.log(`💰 Sending ${sendAmount} RUNE to ${toAddress}`); | ||
console.log(`💰 Asset value: ${assetValue.assetValue}`); | ||
try { | ||
const connectedWallets = client.connectedWallets; | ||
return connectedWallets.THOR?.transfer({ | ||
from, | ||
assetValue, | ||
recipient: toAddress, | ||
memo: '', | ||
}) | ||
.then((txHash) => { | ||
console.log(txHash); | ||
return txHash; | ||
}) | ||
.catch((err) => { | ||
console.log(err); | ||
return ''; | ||
}); | ||
} catch (error) { | ||
console.error(error); | ||
} | ||
} catch (error) { | ||
console.error(error); | ||
return ''; | ||
} | ||
}; | ||
|
||
const main = async () => { | ||
const tx = await doSend({ | ||
sendAmount: 0.1, | ||
toAddress: 'thor1e9lxzfl7x2zvxnjczf8v0urel8943nesq9c4pk', | ||
}); | ||
console.log(tx); | ||
}; | ||
|
||
main(); |
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,25 @@ | ||
{ | ||
"dependencies": { | ||
"@swapkit/core": "../../packages/swapkit/core/src/index.ts", | ||
"@swapkit/helpers": "../../packages/swapkit/helpers/src/index.ts/index.ts", | ||
"@swapkit/types": "../../packages/swapkit/types/src/index.ts", | ||
"@swapkit/wallet-keystore": "../../packages/wallets/keystore/src/index.ts", | ||
"@swapkit/toolbox-cosmos": "../../packages/toolboxes/cosmos/src/index.ts", | ||
"@swapkit/toolbox-evm": "../../packages/toolboxes/evm/src/index.ts", | ||
"@swapkit/toolbox-utxo": "../../packages/toolboxes/utxo/src/index.ts" | ||
}, | ||
"devDependencies": { | ||
"bun-types": "1.0.7" | ||
}, | ||
"eslintConfig": { | ||
"extends": "../../internal/eslint-config" | ||
}, | ||
"private": true, | ||
"scripts": { | ||
"dev:node": "ts-node ./index.ts", | ||
"dev:bun": "bun run ./index.ts", | ||
"preview-playground": "vite preview" | ||
}, | ||
"type": "module" | ||
} | ||
|
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,25 @@ | ||
{ | ||
"compilerOptions": { | ||
"allowJs": false, | ||
"allowSyntheticDefaultImports": true, | ||
"baseUrl": "./src", | ||
"composite": true, | ||
"esModuleInterop": true, | ||
"forceConsistentCasingInFileNames": true, | ||
"isolatedModules": true, | ||
"jsx": "react-jsx", | ||
"lib": ["dom", "dom.iterable", "ESNext"], | ||
"module": "ESNext", | ||
"moduleResolution": "bundler", | ||
"noEmit": true, | ||
"noFallthroughCasesInSwitch": true, | ||
"noImplicitAny": true, | ||
"noUnusedLocals": true, | ||
"noUnusedParameters": true, | ||
"resolveJsonModule": true, | ||
"skipLibCheck": true, | ||
"strict": true, | ||
"strictNullChecks": true, | ||
"target": "ESNext", | ||
} | ||
} |
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 was deleted.
Oops, something went wrong.
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.