Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the import content to work with the new SDK contract client #2

Merged
merged 3 commits into from
May 1, 2024
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
16 changes: 14 additions & 2 deletions initialize.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,16 @@ for (const key in process.env) {
}
}

// The stellar-sdk Client requires (for now) a defined public key. These are
// the Genesis accounts for each of the "typical" networks, and should work as
// a valid, funded network account.
const GENESIS_ACCOUNTS = {
public: 'GAAZI4TCR3TY5OJHCTJC2A4QSY6CJWJH5IAJTGKIN2ER7LBNVKOCCWN7',
testnet: 'GBRPYHIL2CI3FNQ4BXLFMNDLFJUNPU2HY3ZMFSHONUCEOASW7QC7OX2H',
futurenet: 'GADNDFP7HM3KFVHOQBBJDBGRONMKQVUYKXI6OYNDMS2ZIK7L6HA3F2RF',
standalone: 'GBZXN7PIRZGNMHGA7MUUUF4GWPY5AYPV6LY4UV2GL6VJGIQRXFDNMADI',
}

console.log("###################### Initializing ########################");

// Get dirname (equivalent to the Bash version)
Expand Down Expand Up @@ -51,7 +61,7 @@ function deploy_all() {
mkdirSync(contractsDir, { recursive: true });

const wasmFiles = readdirSync(`${dirname}/target/wasm32-unknown-unknown/release`).filter(file => file.endsWith('.wasm'));

wasmFiles.forEach(wasmFile => {
deploy(`${dirname}/target/wasm32-unknown-unknown/release/${wasmFile}`);
});
Expand Down Expand Up @@ -82,9 +92,11 @@ function importContract(contract) {
const importContent =
`import * as Client from '${filenameNoExt}';\n` +
`import { rpcUrl } from './util';\n\n` +
`export default new Client.Contract({\n` +
`export default new Client.Client({\n` +
` ...Client.networks.${process.env.SOROBAN_NETWORK},\n` +
` rpcUrl,\n` +
`${process.env.SOROBAN_NETWORK === 'local' || 'standalone' ? ` allowHttp: true,\n` : null}` +
` publicKey: '${GENESIS_ACCOUNTS[process.env.SOROBAN_NETWORK]}',\n` +
`});\n`;

const outputPath = `${outputDir}/${filenameNoExt}.ts`;
Expand Down
2 changes: 1 addition & 1 deletion src/contracts/util.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
export const rpcUrl = import.meta.env.PUBLIC_SOROBAN_RPC_URL ?? "http://localhost:8000/"
export const rpcUrl = import.meta.env.PUBLIC_SOROBAN_RPC_URL ?? "http://localhost:8000/rpc"
export const networkPassphrase = import.meta.env.PUBLIC_SOROBAN_NETWORK_PASSPHRASE ?? "Standalone Network ; February 2017"