-
Notifications
You must be signed in to change notification settings - Fork 9
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
21 changed files
with
619 additions
and
19 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,175 @@ | ||
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore | ||
|
||
# Logs | ||
|
||
logs | ||
_.log | ||
npm-debug.log_ | ||
yarn-debug.log* | ||
yarn-error.log* | ||
lerna-debug.log* | ||
.pnpm-debug.log* | ||
|
||
# Caches | ||
|
||
.cache | ||
|
||
# Diagnostic reports (https://nodejs.org/api/report.html) | ||
|
||
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json | ||
|
||
# Runtime data | ||
|
||
pids | ||
_.pid | ||
_.seed | ||
*.pid.lock | ||
|
||
# Directory for instrumented libs generated by jscoverage/JSCover | ||
|
||
lib-cov | ||
|
||
# Coverage directory used by tools like istanbul | ||
|
||
coverage | ||
*.lcov | ||
|
||
# nyc test coverage | ||
|
||
.nyc_output | ||
|
||
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files) | ||
|
||
.grunt | ||
|
||
# Bower dependency directory (https://bower.io/) | ||
|
||
bower_components | ||
|
||
# node-waf configuration | ||
|
||
.lock-wscript | ||
|
||
# Compiled binary addons (https://nodejs.org/api/addons.html) | ||
|
||
build/Release | ||
|
||
# Dependency directories | ||
|
||
node_modules/ | ||
jspm_packages/ | ||
|
||
# Snowpack dependency directory (https://snowpack.dev/) | ||
|
||
web_modules/ | ||
|
||
# TypeScript cache | ||
|
||
*.tsbuildinfo | ||
|
||
# Optional npm cache directory | ||
|
||
.npm | ||
|
||
# Optional eslint cache | ||
|
||
.eslintcache | ||
|
||
# Optional stylelint cache | ||
|
||
.stylelintcache | ||
|
||
# Microbundle cache | ||
|
||
.rpt2_cache/ | ||
.rts2_cache_cjs/ | ||
.rts2_cache_es/ | ||
.rts2_cache_umd/ | ||
|
||
# Optional REPL history | ||
|
||
.node_repl_history | ||
|
||
# Output of 'npm pack' | ||
|
||
*.tgz | ||
|
||
# Yarn Integrity file | ||
|
||
.yarn-integrity | ||
|
||
# dotenv environment variable files | ||
|
||
.env | ||
.env.development.local | ||
.env.test.local | ||
.env.production.local | ||
.env.local | ||
|
||
# parcel-bundler cache (https://parceljs.org/) | ||
|
||
.parcel-cache | ||
|
||
# Next.js build output | ||
|
||
.next | ||
out | ||
|
||
# Nuxt.js build / generate output | ||
|
||
.nuxt | ||
dist | ||
|
||
# Gatsby files | ||
|
||
# Comment in the public line in if your project uses Gatsby and not Next.js | ||
|
||
# https://nextjs.org/blog/next-9-1#public-directory-support | ||
|
||
# public | ||
|
||
# vuepress build output | ||
|
||
.vuepress/dist | ||
|
||
# vuepress v2.x temp and cache directory | ||
|
||
.temp | ||
|
||
# Docusaurus cache and generated files | ||
|
||
.docusaurus | ||
|
||
# Serverless directories | ||
|
||
.serverless/ | ||
|
||
# FuseBox cache | ||
|
||
.fusebox/ | ||
|
||
# DynamoDB Local files | ||
|
||
.dynamodb/ | ||
|
||
# TernJS port file | ||
|
||
.tern-port | ||
|
||
# Stores VSCode versions used for testing VSCode extensions | ||
|
||
.vscode-test | ||
|
||
# yarn v2 | ||
|
||
.yarn/cache | ||
.yarn/unplugged | ||
.yarn/build-state.yml | ||
.yarn/install-state.gz | ||
.pnp.* | ||
|
||
# IntelliJ based IDEs | ||
.idea | ||
|
||
# Finder (MacOS) folder config | ||
.DS_Store |
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,6 @@ | ||
{ | ||
"semi": true, | ||
"singleQuote": true, | ||
"tabWidth": 2, | ||
"trailingComma": "es5" | ||
} |
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,15 @@ | ||
# polimec-chopstick-tests | ||
|
||
To install dependencies: | ||
|
||
```bash | ||
bun install | ||
``` | ||
|
||
To run: | ||
|
||
```bash | ||
bun run index.ts | ||
``` | ||
|
||
This project was created using `bun init` in bun v1.1.30. [Bun](https://bun.sh) is a fast all-in-one JavaScript runtime. |
Binary file not shown.
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 @@ | ||
console.log('Hello via Bun!'); |
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,23 @@ | ||
{ | ||
"name": "polimec-chopstick-tests", | ||
"module": "index.ts", | ||
"type": "module", | ||
"devDependencies": { | ||
"@acala-network/chopsticks": "0.12.2", | ||
"@acala-network/chopsticks-testing": "0.12.2", | ||
"@types/bun": "latest", | ||
"prettier": "^3.3.3" | ||
}, | ||
"peerDependencies": { | ||
"typescript": "^5.0.0" | ||
}, | ||
"dependencies": { | ||
"@polkadot/keyring": "^13.2.2", | ||
"@polkadot/types-augment": "^14.2.2", | ||
"@polkadot/util": "^13.2.2", | ||
"@polkadot/util-crypto": "^13.2.2" | ||
}, | ||
"scripts": { | ||
"fmt": "bun prettier --write ." | ||
} | ||
} |
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,149 @@ | ||
import { | ||
setupContext, | ||
type SetupOption, | ||
} from '@acala-network/chopsticks-testing'; | ||
|
||
import type { Config } from './types.js'; | ||
import { initialBalanceDOT, toNumber } from '../utils.js'; | ||
import {type StagingXcmV4Location} from '@polkadot/types/lookup'; | ||
|
||
/// Options used to create the Spiritnet context | ||
export const getSetupOptions = ({ | ||
blockNumber = undefined, | ||
wasmOverride = undefined, | ||
}: { | ||
blockNumber?: number; | ||
wasmOverride?: string; | ||
}) => | ||
({ | ||
endpoint: | ||
process.env.ASSETHUB_WSS || 'wss://asset-hub-polkadot-rpc.dwellir.com', | ||
db: './db/assethub.db.sqlite', | ||
port: toNumber(process.env.ASSETHUB_PORT) || 9003, | ||
wasmOverride, | ||
blockNumber, | ||
}) as SetupOption; | ||
|
||
/// AssetHub has no own coin. Teleported dots are used as the native token. | ||
export function assignDotTokensToAccountsAsStorage( | ||
addr: string[], | ||
balance: bigint = initialBalanceDOT | ||
) { | ||
return { | ||
System: { | ||
Account: addr.map((address) => [ | ||
[address], | ||
{ providers: 1, data: { free: balance.toString() } }, | ||
]), | ||
}, | ||
}; | ||
} | ||
|
||
export function createForeignAsset(manager: string, assetId: StagingXcmV4Location) { | ||
return { | ||
foreignAssets: { | ||
asset: [ | ||
[ | ||
[assetId], | ||
{ | ||
owner: manager, | ||
issuer: manager, | ||
admin: manager, | ||
freezer: manager, | ||
// Just make it big enough | ||
supply: '10000000000000000000000000000', | ||
deposit: 0, | ||
minBalance: 0, | ||
isSufficient: false, | ||
accounts: 0, | ||
sufficients: 0, | ||
approvals: 0, | ||
status: 'Live', | ||
}, | ||
], | ||
], | ||
}, | ||
}; | ||
} | ||
|
||
/// Assigns KSM to an account | ||
export function assignKSMtoAccounts( | ||
addr: string[], | ||
balance: bigint = initialBalanceDOT | ||
) { | ||
return { | ||
foreignAssets: { | ||
account: addr.map((addr) => [ | ||
[KSMAssetLocation, addr], | ||
{ | ||
balance: balance, | ||
status: 'Liquid', | ||
reason: 'Consumer', | ||
extra: null, | ||
}, | ||
]), | ||
}, | ||
}; | ||
} | ||
|
||
/// Assigns the foreign asset to the accounts. | ||
/// Does not check if supply is matching the sum of the account balances. | ||
export function assignForeignAssetToAccounts( | ||
accountInfo: [string, bigint][], | ||
assetId = eKiltLocation | ||
) { | ||
return { | ||
foreignAssets: { | ||
account: accountInfo.map(([account, balance]) => [ | ||
[assetId, account], | ||
{ | ||
balance: balance, | ||
status: 'Liquid', | ||
reason: 'Consumer', | ||
extra: null, | ||
}, | ||
]), | ||
}, | ||
}; | ||
} | ||
|
||
/// AssetHub ParaId | ||
export const paraId = 1000; | ||
|
||
export const KSMAssetLocation = { | ||
parents: 2, | ||
interior: { | ||
X1: { | ||
GlobalConsensus: 'Kusama', | ||
}, | ||
}, | ||
}; | ||
|
||
// Sibling Sovereign Account | ||
export const sovereignAccountOnSiblingChains = | ||
'4qXPdpimHh8TR24RSk994yVzxx4TLfvKj5i1qH5puvWmfAqy'; | ||
|
||
/// Native token in AssetHub | ||
export const nativeTokenLocation = { parents: 1, interior: 'Here' }; | ||
|
||
export const eKiltLocation = { | ||
parents: 2, | ||
interior: { | ||
X2: [ | ||
{ | ||
GlobalConsensus: { Ethereum: { chainId: 11155111 } }, | ||
}, | ||
{ | ||
AccountKey20: { | ||
network: null, | ||
key: '0x06012c8cf97bead5deae237070f9587f8e7a266d', | ||
}, | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
export async function getContext(): Promise<Config> { | ||
const options = getSetupOptions({}); | ||
return setupContext(options); | ||
} |
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,3 @@ | ||
import type { setupContext } from '@acala-network/chopsticks-testing'; | ||
|
||
export type Config = Awaited<ReturnType<typeof setupContext>>; |
Oops, something went wrong.