Skip to content

Commit

Permalink
chore(xcm-tools): Update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dudo50 committed Nov 15, 2024
1 parent 54d0d46 commit 66f9278
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 12 deletions.
6 changes: 3 additions & 3 deletions apps/xcm-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ const response = await fetch('http://localhost:3001/x-transfer-hash', {
body: JSON.stringify({
from: 'Parachain', // Replace "Parachain" with sender Parachain, e.g., "Acala"
to: 'Parachain', // Replace "Parachain" with destination Parachain, e.g., "Moonbeam" or custom Multilocation
currency: { currencySpec }, // {id: currencyID} | {symbol: currencySymbol}, | {multilocation: multilocationJson} | {multiasset: multilocationJsonArray}
currency: { currencySpec }, //{id: currencyID} | {symbol: currencySymbol} | {"symbol": {"type": "Native","value": "currencySymbol"} | {"symbol": {"type": "Foreign","value": "currencySymbol"} | {"symbol": {"type": "ForeignAbstract","value": "currencySymbolAlias"} | {multilocation: AssetMultilocationString} | {multilocation: AssetMultilocationJson} | {multilocation: "type": "Override","value": "CustomAssetMultilocationJson"} | {multiasset: multilocationJsonArray}
amount: 'Amount', // Replace "Amount" with the numeric value you wish to transfer
address: 'Address', // Replace "Address" with destination wallet address (In AccountID32 or AccountKey20 Format) or custom Multilocation
//xcmVersion: "Vx" //Optional parameter - replace "Vx" with V and version number eg. "V4"
Expand Down Expand Up @@ -189,7 +189,7 @@ const response = await fetch('http://localhost:3001/transfer-info?', {
body: JSON.stringify({
origin: 'Parachain', // Replace "Parachain" with chain you wish to query transfer info for as origin
destination: 'Parachain', // Replace "Parachain" with chain you wish to query transfer info for as destination
currency: { currencySpec }, //{id: currencyID} | {symbol: currencySymbol}
currency: { currencySpec }, //{id: currencyID} | {symbol: currencySymbol} | {"symbol": {"type": "Native","value": "currencySymbol"} | {"symbol": {"type": "Foreign","value": "currencySymbol"} | {"symbol": {"type": "ForeignAbstract","value": "currencySymbolAlias"} | {multilocation: AssetMultilocationString} | {multilocation: AssetMultilocationJson}
amount: 'Amount', // Replace "Amount" with the numeric value you wish to transfer
accountOrigin: 'Account address', // Replace "Address" with origin wallet address (In AccountID32 or AccountKey20 Format)
accountDestination: 'Account address', // Replace "Address" with destination wallet address (In AccountID32 or AccountKey20 Format)
Expand Down Expand Up @@ -336,7 +336,7 @@ const response = await fetch("http://localhost:3001/balance/:node/foreign", {
},
body: JSON.stringify({
address: "Address" // Replace "Address" with wallet address (In AccountID32 or AccountKey20 Format)
currency: "Currency" //Replace "Currency" with either symbol { symbol: "KSM" } or id { id: 123 }
currency: "Currency" //Replace "Currency" with either {id: currencyID} | {symbol: currencySymbol} | {"symbol": {"type": "Native","value": "currencySymbol"} | {"symbol": {"type": "Foreign","value": "currencySymbol"} | {"symbol": {"type": "ForeignAbstract","value": "currencySymbolAlias"} | {multilocation: AssetMultilocationString} | {multilocation: AssetMultilocationJson}
})
});
```
Expand Down
20 changes: 11 additions & 9 deletions packages/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ NOTES:
```
Latest news:
- ParaSpell now offers advanced asset symbol selection {symbol: "symbol"} for non duplicate assets, {symbol: Native("symbol")} or {symbol: Foreign("symbol")} if the duplicates are between native and foreign assets and {symbol: ForeignAbstract("symbol")} if the duplicates are in foreign assets only. You will get an error that will guide you further if you simply start with {symbol: "symbol"}.
- You can now select assets by multilocation by simply using { multilocation: string | JSON }. The custom multilocation selection remains supported, but in order to use it you now have to use override - {multilocation: Override('Custom Multilocation')}.
- The balance queries also support multilocation asset selection
```

### Builder pattern:
Expand All @@ -113,7 +115,7 @@ Latest news:
await Builder(/*node api/ws_url_string - optional*/)
.from(NODE)
.to(NODE /*,customParaId - optional*/ | Multilocation object /*Only works for PolkadotXCM pallet*/)
.currency({id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: multilocationJson} | {multiasset: multilocationJsonArray})
.currency({id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson} | {multilocation: Override('Custom Multilocation')} | {multiasset: multilocationJsonArray})
/*.feeAsset(feeAsset) - Parameter required when using MultilocationArray*/
.amount(amount) // Overriden when using MultilocationArray
.address(address | Multilocation object /*If you are sending through xTokens, you need to pass the destination and address multilocation in one object (x2)*/)
Expand All @@ -122,9 +124,9 @@ await Builder(/*node api/ws_url_string - optional*/)
/*
EXAMPLE:
await Builder()
.from('Basilisk')
.to('Robonomics')
.currency({symbol:'XRT'})
.from('Hydration')
.to('BifrostPolkadot')
.currency({symbol:'BNC'})
.amount(1000000000000)
.address('4FCUYBMe2sbq5KosN22emsPUydS8XUwZhJ6VUZesmouGu6qd')
.build()
Expand Down Expand Up @@ -214,7 +216,7 @@ await paraspell.xcmPallet.send(
{
api?: ApiPromise/Ws_url_string,
origin: origin Parachain name string,
currency: {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: multilocationJson} | {multiasset: multilocationJsonArray}) ,
currency: {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson} | {multilocation: Override('Custom Multilocation')} | {multiasset: multilocationJsonArray} ,
feeAsset? - Fee asset select id
amount: any,
to: destination address string | Multilocation object,
Expand Down Expand Up @@ -332,19 +334,19 @@ import { getTransferInfo, getBalanceForeign, getBalanceNative, getOriginFeeDetai
import { getTransferInfo, getBalanceForeign, getBalanceNative, getOriginFeeDetails } from "@paraspell/sdk/papi";

//Get balance of foreign currency
await getBalanceForeign({address, node, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, api /* api/ws_url_string optional */})
await getBalanceForeign({address, node, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/, api /* api/ws_url_string optional */})

//Get balance of native currency
await getBalanceNative({address, node, api /* api/ws_url_string optional */})

//Get fee information regarding XCM call
await getOriginFeeDetails({from, to, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, amount, originAddress, destinationAddress, api /* api/ws_url_string optional */, feeMargin /* 10% by default */})
await getOriginFeeDetails({from, to, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/, amount, originAddress, destinationAddress, api /* api/ws_url_string optional */, feeMargin /* 10% by default */})

//Retrieves the asset balance for a given account on a specified node.
await getAssetBalance({address, node, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, api /* api/ws_url_string optional */});
await getAssetBalance({address, node, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/, api /* api/ws_url_string optional */});

//Get all the information about XCM transfer
await getTransferInfo({from, to, address, destinationAddress, currency /*- {id: currencyID} | {symbol: currencySymbol}*/, amount, api /* api/ws_url_string optional */})
await getTransferInfo({from, to, address, destinationAddress, currency /*- {id: currencyID} | {symbol: currencySymbol} | {symbol: Native('currencySymbol')} | {symbol: Foreign('currencySymbol')} | {symbol: ForeignAbstract('currencySymbol')} | {multilocation: AssetMultilocationString | AssetMultilocationJson}*/, amount, api /* api/ws_url_string optional */})
```

## 💻 Tests
Expand Down

0 comments on commit 66f9278

Please sign in to comment.