Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
54 changes: 49 additions & 5 deletions README-es.md
Original file line number Diff line number Diff line change
Expand Up @@ -161,8 +161,32 @@ Si quieres hacer pruebas en Testnet, tienes Rococo.
</br>
Consigue algunos activos: <a href="https://app.element.io/#/room/#rococo-faucet:matrix.org">Rococo faucet</a>

### Config
Los ejemplos están en ./examples/rococo/, puede poner tu configuración en ./examples/rococo/rococo-examples-util.ts. Luego puedes ejecutar un comando por cada ejemplo. Si quieres ejecutarlos de forma manual, debes crear tu propio script (.js o .ts) e importar las dependencias.

```ts
export const rococoExampleUtils = {
rococoRpc: 'wss://rococo-rpc.polkadot.io',
rockMineRpc: 'wss://rococo-rockmine-rpc.polkadot.io',
rockMineParachainId: 1000,
daliParachainId: 2087,
senderMnemonic: '<your account mnemonic>',
rockmineDestinationAccount: '<rockmine address account>',
daliDestinationAccount: '<dali destination account>',
rococoDestinationAccount: '<rococo address account>',
rocAmount: <amount to transfer>,
}
```

### Enviar activos de Rococo a Rockmine

comando:
```ts
npx ts-node src/examples/rococo/rococo-to-rockmine.ts
```

manual:

```ts
const destination = "Parachain";
const destinationValue = 2000; // Rockmine parchain id
Expand All @@ -180,6 +204,12 @@ const res = await provider.limitedTeleportAssets({
```

### Enviar activos de RockMine a Rococo
comando:
```ts
npx ts-node src/examples/rococo/rockmine-to-rococo.ts
```

manual:

```ts
const destinationParents = 1; // Destination to Rococo
Expand All @@ -197,6 +227,12 @@ const res = await provider.limitedTeleportAssets({
```

### Enviar activos nativos (ROC) de RockMine a Dali
comando:
```ts
npx ts-node src/examples/rococo/rockmine-to-dali-roc.ts
```

manual:

```ts
const destination = "Parachain";
Expand All @@ -219,13 +255,21 @@ const res = await provider.limitedReserveTransferAssets({
```

### Enviar activo de Rococo a Dali
Asegurate de tener <a href="https://polkadot.js.org/apps/#/assets/balances"> activos </a> para transferir. También es necesario cambiar el id del activo en ./examples/rococo/rockmine-to-dali-asset.ts, el valor por defecto es 1984 (Rockmine USD).

```ts
const destination = "Parachain";
const destinationValue = 2087;
const beneficiary = "AccountId32";
const beneficiaryValue = "<dali account address>";
const amount = 1000000000000000;
npx ts-node src/examples/rococo/rockmine-to-dali-asset.ts
```

manualy
```ts
const destination = "Parachain"
const destinationValue = 2087
const destinationParents = 1
const beneficiary = 'AccountId32'
const beneficiaryValue = "<dali account address>"
const assetId = 1984 // asset id in rockmine
const amount = 50000000000

const res = await provider.limitedReserveTransferAssets({
destination,
Expand Down
60 changes: 55 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,31 @@ If you want to tests in Testnet, you have Rococo.
Get some assets: <a href="https://app.element.io/#/room/#rococo-faucet:matrix.org">Rococo faucet</a>


### Config
The examples are in ./examples/rococo/, you can put your configuration in ./examples/rococo/rococo-examples-util.ts. Then you can run a command for each example. If you want to run them manually, you must create your own script (.js or ts) and import the dependencies.

```ts
export const rococoExampleUtils = {
rococoRpc: 'wss://rococo-rpc.polkadot.io',
rockMineRpc: 'wss://rococo-rockmine-rpc.polkadot.io',
rockMineParachainId: 1000,
daliParachainId: 2087,
senderMnemonic: '<your account mnemonic>',
rockmineDestinationAccount: '<rockmine address account>',
daliDestinationAccount: '<dali destination account>',
rococoDestinationAccount: '<rococo address account>',
rocAmount: <amount to transfer>,
}
```

### Send Asset from Rococo to Rockmine

command:
```ts
npx ts-node src/examples/rococo/rococo-to-rockmine.ts
```

manually:
```ts
const destination = "Parachain"
const destinationValue = 2000 // Rockmine parchain id
Expand All @@ -180,6 +204,14 @@ Get some assets: <a href="https://app.element.io/#/room/#rococo-faucet:matrix.or
```

### Send Asset from RockMine to Rococo

command:
```ts
npx ts-node src/examples/rococo/rockmine-to-rococo.ts
```

manualy:

```ts
const destinationParents = 1; // Destination to Rococo
const beneficiary = "AccountId32"
Expand All @@ -197,6 +229,12 @@ Get some assets: <a href="https://app.element.io/#/room/#rococo-faucet:matrix.or
```

### Send native Asset (ROC) from RockMine to Dali
command:
```ts
npx ts-node src/examples/rococo/rockmine-to-dali-roc.ts
```

manualy:
```ts
const destination = "Parachain";
const destinationValue = 2087; // dali parachain id
Expand All @@ -218,12 +256,22 @@ Get some assets: <a href="https://app.element.io/#/room/#rococo-faucet:matrix.or
```

### Send Asset from Rococo to dali

Make sure you have <a href="https://polkadot.js.org/apps/#/assets/balances"> assets </a> to transfer. It is also necessary to change the asset id in ./examples/rococo/rockmine-to-dali-asset.ts, default is 1984 (Rockmine USD).

```ts
const destination = "Parachain";
const destinationValue = 2087;
const beneficiary = "AccountId32";
const beneficiaryValue = "<dali account address>";
const amount = 1000000000000000;
npx ts-node src/examples/rococo/rockmine-to-dali-asset.ts
```

manualy
```ts
const destination = "Parachain"
const destinationValue = 2087
const destinationParents = 1
const beneficiary = 'AccountId32'
const beneficiaryValue = "<dali account address>"
const assetId = 1984 // asset id in rockmine
const amount = 50000000000


const res = await provider.limitedReserveTransferAssets({
Expand All @@ -235,6 +283,8 @@ Get some assets: <a href="https://app.element.io/#/room/#rococo-faucet:matrix.or
});
```



## Testing

Running the unit tests.
Expand Down
10 changes: 5 additions & 5 deletions src/tests/mocks/provider-mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const XCM_PALLET_RESPONSES = {

export const xcmPalletMock = {
reserveTransferAssets: () => ({
signAndSend: (signer: any, cb: any) => {
signAndSend: (_signer: any, cb: any) => {
const status = { isInBlock: true }
const txHash = XCM_PALLET_RESPONSES.reserveTransferAssets
const dispatchError = ''
Expand All @@ -35,7 +35,7 @@ export const xcmPalletMock = {
},
}),
limitedReserveTransferAssets: () => ({
signAndSend: (signer: any, cb: any) => {
signAndSend: (_signer: any, cb: any) => {
const status = { isInBlock: true }
const txHash = XCM_PALLET_RESPONSES.limitedReserveTransferAssets
const dispatchError = ''
Expand All @@ -50,7 +50,7 @@ export const xcmPalletMock = {
},
}),
teleportAssets: () => ({
signAndSend: (signer: any, cb: any) => {
signAndSend: (_signer: any, cb: any) => {
const status = { isInBlock: true }
const txHash = XCM_PALLET_RESPONSES.teleportAssets
const dispatchError = ''
Expand All @@ -65,7 +65,7 @@ export const xcmPalletMock = {
},
}),
limitedTeleportAssets: () => ({
signAndSend: (signer: any, cb: any) => {
signAndSend: (_signer: any, cb: any) => {
const status = { isInBlock: true, isFinalized: true }
const txHash = XCM_PALLET_RESPONSES.limitedTeleportAssets
const dispatchError = ''
Expand All @@ -80,7 +80,7 @@ export const xcmPalletMock = {
},
}),
limitedTeleportAssetsWithError: () => ({
signAndSend: (signer: any, cb: any) => {
signAndSend: (_signer: any, cb: any) => {
const status = { isInBlock: true, isFinalized: true }
const txHash = XCM_PALLET_RESPONSES.limitedTeleportAssets
const dispatchError = {
Expand Down
8 changes: 5 additions & 3 deletions src/tests/provider.spec.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ApiPromise } from '@polkadot/api'
import { ApiPromise, WsProvider } from '@polkadot/api'
import * as Keyring from '@polkadot/keyring'
import { assert, expect } from 'chai'
import sinon from 'sinon'
Expand All @@ -10,6 +10,8 @@ describe('Provider', () => {
sinon.stub(Keyring, 'default').returns({
addFromMnemonic: () => SIGNER_MOCK,
})

sinon.stub(WsProvider.prototype, 'connect').resolves()
})

afterEach(() => {
Expand All @@ -26,7 +28,7 @@ describe('Provider', () => {
expect(provider.signer).to.equal(SIGNER_MOCK)
})

it('should save injecto signer', () => {
it('should save inject signer', () => {
const rpc = chainSpecsMock.rpc
const accountId = '0x12345'

Expand Down Expand Up @@ -75,7 +77,7 @@ describe('Provider', () => {
limitedTeleportAssets: xcmPalletMock.limitedTeleportAssets,
},
},
setSigner: (signer: any) => null,
setSigner: () => null,
} as any)

const sender = '0x12345'
Expand Down
2 changes: 1 addition & 1 deletion src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ export const makeAsssetMultiAsset = ({
return xcmVersionedMultiLocation
}

export const formatExtrinsicResponse = ({ api, res, rej, status, txHash, dispatchError, dispatchInfo }: any) => {
export const formatExtrinsicResponse = ({ res, rej, status, txHash, dispatchError, dispatchInfo }: any) => {
if (status.isInBlock || status.isFinalized) {
if (dispatchError) {
rej(dispatchError.toString())
Expand Down