Skip to content

Commit

Permalink
added tokens bankrun
Browse files Browse the repository at this point in the history
  • Loading branch information
heyAyushh committed Aug 20, 2024
1 parent 1da7a16 commit a69fcb1
Show file tree
Hide file tree
Showing 10 changed files with 381 additions and 107 deletions.
2 changes: 1 addition & 1 deletion biome.json
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,6 @@
},
"files": {
"ignore": ["node_modules"],
"include": ["**/*.ts", "**/*.js", "**/*.json"]
"include": ["**/*.ts", "**/*.js", "**/*.json", "**/*.mjs"]
}
}
35 changes: 19 additions & 16 deletions tokens/create-token/anchor/prepare.mjs
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
#!/usr/bin/env zx

import { $ } from 'zx'
import { mkdir, rm } from 'node:fs/promises'
import { join } from 'node:path'
import { mkdir, rm } from 'node:fs/promises';
import { join } from 'node:path';
import { $ } from 'zx';

const programs = [{
id: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
name: 'token_metadata.so',
}]
const programs = [
{
id: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
name: 'token_metadata.so',
},
];

const outputDir = 'tests/fixtures'
const overwrite = true
const outputDir = 'tests/fixtures';
const overwrite = true;

try {
for (const program of programs) {
const { id, name } = program;
const outputFile = join(outputDir, name)
const outputFile = join(outputDir, name);
await $`solana config set -um`;

try {
await mkdir(outputDir, { recursive: true })
if (overwrite) await rm(outputFile, { force: true })
await $`solana program dump ${id} ${outputFile}`
console.log(`Program ${id} dumped to ${outputFile}`)
await mkdir(outputDir, { recursive: true });
if (overwrite) await rm(outputFile, { force: true });
await $`solana program dump ${id} ${outputFile}`;
console.log(`Program ${id} dumped to ${outputFile}`);
} catch (error) {
console.error(`Error dumping ${id}: ${error.message}`)
console.error(`Error dumping ${id}: ${error.message}`);
}
}
} catch (error) {
console.error(`Error preparing programs: ${error.message}`)
console.error(`Error preparing programs: ${error.message}`);
}
35 changes: 19 additions & 16 deletions tokens/nft-minter/anchor/prepare.mjs
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
#!/usr/bin/env zx

import { $ } from 'zx'
import { mkdir, rm } from 'node:fs/promises'
import { join } from 'node:path'
import { mkdir, rm } from 'node:fs/promises';
import { join } from 'node:path';
import { $ } from 'zx';

const programs = [{
id: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
name: 'token_metadata.so',
}]
const programs = [
{
id: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
name: 'token_metadata.so',
},
];

const outputDir = 'tests/fixtures'
const overwrite = true
const outputDir = 'tests/fixtures';
const overwrite = true;

try {
for (const program of programs) {
const { id, name } = program;
const outputFile = join(outputDir, name)
const outputFile = join(outputDir, name);
await $`solana config set -um`;

try {
await mkdir(outputDir, { recursive: true })
if (overwrite) await rm(outputFile, { force: true })
await $`solana program dump ${id} ${outputFile}`
console.log(`Program ${id} dumped to ${outputFile}`)
await mkdir(outputDir, { recursive: true });
if (overwrite) await rm(outputFile, { force: true });
await $`solana program dump ${id} ${outputFile}`;
console.log(`Program ${id} dumped to ${outputFile}`);
} catch (error) {
console.error(`Error dumping ${id}: ${error.message}`)
console.error(`Error dumping ${id}: ${error.message}`);
}
}
} catch (error) {
console.error(`Error preparing programs: ${error.message}`)
console.error(`Error preparing programs: ${error.message}`);
}
35 changes: 19 additions & 16 deletions tokens/nft-operations/anchor/prepare.mjs
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
#!/usr/bin/env zx

import { $ } from 'zx'
import { mkdir, rm } from 'node:fs/promises'
import { join } from 'node:path'
import { mkdir, rm } from 'node:fs/promises';
import { join } from 'node:path';
import { $ } from 'zx';

const programs = [{
id: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
name: 'token_metadata.so',
}]
const programs = [
{
id: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
name: 'token_metadata.so',
},
];

const outputDir = 'tests/fixtures'
const overwrite = true
const outputDir = 'tests/fixtures';
const overwrite = true;

try {
for (const program of programs) {
const { id, name } = program;
const outputFile = join(outputDir, name)
const outputFile = join(outputDir, name);
await $`solana config set -um`;

try {
await mkdir(outputDir, { recursive: true })
if (overwrite) await rm(outputFile, { force: true })
await $`solana program dump ${id} ${outputFile}`
console.log(`Program ${id} dumped to ${outputFile}`)
await mkdir(outputDir, { recursive: true });
if (overwrite) await rm(outputFile, { force: true });
await $`solana program dump ${id} ${outputFile}`;
console.log(`Program ${id} dumped to ${outputFile}`);
} catch (error) {
console.error(`Error dumping ${id}: ${error.message}`)
console.error(`Error dumping ${id}: ${error.message}`);
}
}
} catch (error) {
console.error(`Error preparing programs: ${error.message}`)
console.error(`Error preparing programs: ${error.message}`);
}
35 changes: 19 additions & 16 deletions tokens/pda-mint-authority/anchor/prepare.mjs
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
#!/usr/bin/env zx

import { $ } from 'zx'
import { mkdir, rm } from 'node:fs/promises'
import { join } from 'node:path'
import { mkdir, rm } from 'node:fs/promises';
import { join } from 'node:path';
import { $ } from 'zx';

const programs = [{
id: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
name: 'token_metadata.so',
}]
const programs = [
{
id: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
name: 'token_metadata.so',
},
];

const outputDir = 'tests/fixtures'
const overwrite = true
const outputDir = 'tests/fixtures';
const overwrite = true;

try {
for (const program of programs) {
const { id, name } = program;
const outputFile = join(outputDir, name)
const outputFile = join(outputDir, name);
await $`solana config set -um`;

try {
await mkdir(outputDir, { recursive: true })
if (overwrite) await rm(outputFile, { force: true })
await $`solana program dump ${id} ${outputFile}`
console.log(`Program ${id} dumped to ${outputFile}`)
await mkdir(outputDir, { recursive: true });
if (overwrite) await rm(outputFile, { force: true });
await $`solana program dump ${id} ${outputFile}`;
console.log(`Program ${id} dumped to ${outputFile}`);
} catch (error) {
console.error(`Error dumping ${id}: ${error.message}`)
console.error(`Error dumping ${id}: ${error.message}`);
}
}
} catch (error) {
console.error(`Error preparing programs: ${error.message}`)
console.error(`Error preparing programs: ${error.message}`);
}
35 changes: 19 additions & 16 deletions tokens/spl-token-minter/anchor/prepare.mjs
Original file line number Diff line number Diff line change
@@ -1,31 +1,34 @@
#!/usr/bin/env zx

import { $ } from 'zx'
import { mkdir, rm } from 'node:fs/promises'
import { join } from 'node:path'
import { mkdir, rm } from 'node:fs/promises';
import { join } from 'node:path';
import { $ } from 'zx';

const programs = [{
id: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
name: 'token_metadata.so',
}]
const programs = [
{
id: 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s',
name: 'token_metadata.so',
},
];

const outputDir = 'tests/fixtures'
const overwrite = true
const outputDir = 'tests/fixtures';
const overwrite = true;

try {
for (const program of programs) {
const { id, name } = program;
const outputFile = join(outputDir, name)
const outputFile = join(outputDir, name);
await $`solana config set -um`;

try {
await mkdir(outputDir, { recursive: true })
if (overwrite) await rm(outputFile, { force: true })
await $`solana program dump ${id} ${outputFile}`
console.log(`Program ${id} dumped to ${outputFile}`)
await mkdir(outputDir, { recursive: true });
if (overwrite) await rm(outputFile, { force: true });
await $`solana program dump ${id} ${outputFile}`;
console.log(`Program ${id} dumped to ${outputFile}`);
} catch (error) {
console.error(`Error dumping ${id}: ${error.message}`)
console.error(`Error dumping ${id}: ${error.message}`);
}
}
} catch (error) {
console.error(`Error preparing programs: ${error.message}`)
console.error(`Error preparing programs: ${error.message}`);
}
8 changes: 7 additions & 1 deletion tokens/transfer-tokens/anchor/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,19 @@
"@coral-xyz/anchor": "^0.30.0",
"@solana/spl-token": "^0.3.8"
},
"scripts": {
"postinstall": "zx prepare.mjs"
},
"devDependencies": {
"@types/bn.js": "^5.1.0",
"@types/chai": "^4.3.0",
"@types/mocha": "^9.0.0",
"anchor-bankrun": "^0.4.0",
"chai": "^4.3.4",
"mocha": "^9.0.3",
"solana-bankrun": "^0.3.0",
"ts-mocha": "^10.0.0",
"typescript": "^4.3.5"
"typescript": "^4.3.5",
"zx": "^8.1.4"
}
}
Loading

0 comments on commit a69fcb1

Please sign in to comment.