-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(frontend): kong_backend integration
- Loading branch information
1 parent
4224882
commit a0005bd
Showing
18 changed files
with
2,630 additions
and
3 deletions.
There are no files selected for viewing
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
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,58 @@ | ||
#!/usr/bin/env bash | ||
set -euo pipefail | ||
|
||
print_help() { | ||
cat <<-EOF | ||
Creates the Kong Backend installation files: | ||
- The Wasm and Candid files are downloaded. | ||
The files are installed at at the locations defined for 'kong_backend' in 'dfx.json'. | ||
EOF | ||
} | ||
|
||
[[ "${1:-}" != "--help" ]] || { | ||
print_help | ||
exit 0 | ||
} | ||
|
||
KONG_REPO_URL="https://raw.githubusercontent.com/KongSwap/kong/refs/heads/main/canisters" | ||
CANDID_URL="${KONG_REPO_URL}/kong_backend.did" | ||
WASM_URL="${KONG_REPO_URL}/kong_backend.wasm.gz" | ||
|
||
CANDID_FILE="$(jq -r .canisters.kong_backend.candid dfx.json)" | ||
WASM_FILE="$(jq -r .canisters.kong_backend.wasm dfx.json)" | ||
|
||
download() { | ||
: 'Downloads a URL to a given file.' | ||
: '* With argument x, the filename is $X_FILE and the URL is $X_URL' | ||
: '* If the file already exists, the user is prompted whether to overwrite, keeping the existing file by default.' | ||
local asset asset_url asset_file response | ||
asset="$1" | ||
asset_url="${asset^^}_URL" | ||
asset_file="${asset^^}_FILE" | ||
: 'If the asset file already exists, ask the user whether to overwrite it.' | ||
if test -e "${!asset_file}" && read -r -p "Overwrite existing ${!asset_file}? [y/N] " response && [[ "${response,,}" != y* ]]; then | ||
echo "Using existing kong $asset file." | ||
else | ||
echo Downloading ${!asset_url} "-->" ${!asset_file} | ||
mkdir -p "$(dirname "${!asset_file}")" | ||
curl -sSL "${!asset_url}" >"${!asset_file}" | ||
fi | ||
} | ||
|
||
#### | ||
# Downloads the candid file, if it does not exist already. | ||
download candid | ||
|
||
#### | ||
# Downloads the Wasm file, if it does not exist already. | ||
download wasm | ||
|
||
#### | ||
# Success | ||
cat <<EOF | ||
SUCCESS: The kong_backend installation files have been created: | ||
kong_backend candid: $CANDID_FILE | ||
kong_backend Wasm: $WASM_FILE | ||
EOF |
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,5 @@ | ||
#!/usr/bin/env bash | ||
|
||
DFX_NETWORK=local | ||
|
||
KONG_BUILDENV="$DFX_NETWORK" dfx deploy kong_backend --network "$DFX_NETWORK" --specified-id l4lgk-raaaa-aaaar-qahpq-cai |
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
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
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
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
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,45 @@ | ||
import type { ActorConfig, ActorSubclass, Agent, HttpAgentOptions } from '@dfinity/agent'; | ||
import type { IDL } from '@dfinity/candid'; | ||
import type { Principal } from '@dfinity/principal'; | ||
|
||
import { _SERVICE } from './kong_backend.did'; | ||
|
||
export declare const idlFactory: IDL.InterfaceFactory; | ||
export declare const canisterId: string; | ||
|
||
export declare interface CreateActorOptions { | ||
/** | ||
* @see {@link Agent} | ||
*/ | ||
agent?: Agent; | ||
/** | ||
* @see {@link HttpAgentOptions} | ||
*/ | ||
agentOptions?: HttpAgentOptions; | ||
/** | ||
* @see {@link ActorConfig} | ||
*/ | ||
actorOptions?: ActorConfig; | ||
} | ||
|
||
/** | ||
* Intializes an {@link ActorSubclass}, configured with the provided SERVICE interface of a canister. | ||
* @constructs {@link ActorSubClass} | ||
* @param {string | Principal} canisterId - ID of the canister the {@link Actor} will talk to | ||
* @param {CreateActorOptions} options - see {@link CreateActorOptions} | ||
* @param {CreateActorOptions["agent"]} options.agent - a pre-configured agent you'd like to use. Supercedes agentOptions | ||
* @param {CreateActorOptions["agentOptions"]} options.agentOptions - options to set up a new agent | ||
* @see {@link HttpAgentOptions} | ||
* @param {CreateActorOptions["actorOptions"]} options.actorOptions - options for the Actor | ||
* @see {@link ActorConfig} | ||
*/ | ||
export declare const createActor: ( | ||
canisterId: string | Principal, | ||
options?: CreateActorOptions | ||
) => ActorSubclass<_SERVICE>; | ||
|
||
/** | ||
* Intialized Actor using default settings, ready to talk to a canister using its candid interface | ||
* @constructs {@link ActorSubClass} | ||
*/ | ||
export declare const kong_backend: ActorSubclass<_SERVICE>; |
Oops, something went wrong.