generated from veeso-dev/rust-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: added marketplace to build scripts
- Loading branch information
Showing
10 changed files
with
561 additions
and
4 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
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,50 @@ | ||
import type { | ||
ActorSubclass, | ||
HttpAgentOptions, | ||
ActorConfig, | ||
Agent, | ||
} from "@dfinity/agent"; | ||
import type { Principal } from "@dfinity/principal"; | ||
import type { IDL } from "@dfinity/candid"; | ||
|
||
import { _SERVICE } from './marketplace.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 marketplace: ActorSubclass<_SERVICE>; |
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,43 @@ | ||
import { Actor, HttpAgent } from "@dfinity/agent"; | ||
|
||
// Imports and re-exports candid interface | ||
import { idlFactory } from "./marketplace.did.js"; | ||
export { idlFactory } from "./marketplace.did.js"; | ||
|
||
/* CANISTER_ID is replaced by webpack based on node environment | ||
* Note: canister environment variable will be standardized as | ||
* process.env.CANISTER_ID_<CANISTER_NAME_UPPERCASE> | ||
* beginning in dfx 0.15.0 | ||
*/ | ||
export const canisterId = | ||
process.env.CANISTER_ID_MARKETPLACE || | ||
process.env.MARKETPLACE_CANISTER_ID; | ||
|
||
export const createActor = (canisterId, options = {}) => { | ||
const agent = options.agent || new HttpAgent({ ...options.agentOptions }); | ||
|
||
if (options.agent && options.agentOptions) { | ||
console.warn( | ||
"Detected both agent and agentOptions passed to createActor. Ignoring agentOptions and proceeding with the provided agent." | ||
); | ||
} | ||
|
||
// Fetch root key for certificate validation during development | ||
if (process.env.DFX_NETWORK !== "ic") { | ||
agent.fetchRootKey().catch((err) => { | ||
console.warn( | ||
"Unable to fetch root key. Check to ensure that your local replica is running" | ||
); | ||
console.error(err); | ||
}); | ||
} | ||
|
||
// Creates an actor with using the candid interface and the HttpAgent | ||
return Actor.createActor(idlFactory, { | ||
agent, | ||
canisterId, | ||
...options.actorOptions, | ||
}); | ||
}; | ||
|
||
export const marketplace = createActor(canisterId); |
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,123 @@ | ||
import type { Principal } from '@dfinity/principal'; | ||
import type { ActorMethod } from '@dfinity/agent'; | ||
|
||
export type AllowanceError = { 'AllowanceNotFound' : null } | | ||
{ 'BadSpender' : null } | | ||
{ 'AllowanceChanged' : null } | | ||
{ 'BadExpiration' : null } | | ||
{ 'AllowanceExpired' : null } | | ||
{ 'InsufficientFunds' : null }; | ||
export type BalanceError = { 'AccountNotFound' : null } | | ||
{ 'InsufficientBalance' : null }; | ||
export type BuyError = { 'TokenHasNoOwner' : null } | | ||
{ 'IcpAllowanceNotEnough' : null } | | ||
{ 'CallerAlreadyOwnsToken' : null } | | ||
{ 'IcpAllowanceExpired' : null }; | ||
export type ConfigurationError = { 'AdminsCantBeEmpty' : null } | | ||
{ 'AnonymousAdmin' : null }; | ||
export type ConfigurationError_1 = { 'CustodialsCantBeEmpty' : null } | | ||
{ 'AnonymousCustodial' : null }; | ||
export type DeferredError = { 'Fly' : FlyError } | | ||
{ 'Nft' : NftError } | | ||
{ 'Configuration' : ConfigurationError_1 } | | ||
{ 'Unauthorized' : null } | | ||
{ 'Token' : TokenError } | | ||
{ 'StorageError' : null } | | ||
{ 'CanisterCall' : [RejectionCode, string] }; | ||
export type FlyError = { 'Configuration' : ConfigurationError } | | ||
{ 'Icrc1Transfer' : TransferError } | | ||
{ 'Pool' : PoolError } | | ||
{ 'Allowance' : AllowanceError } | | ||
{ 'Register' : RegisterError } | | ||
{ 'XrcError' : null } | | ||
{ 'StorageError' : null } | | ||
{ 'CanisterCall' : [RejectionCode, string] } | | ||
{ 'Balance' : BalanceError } | | ||
{ 'Icrc2Transfer' : TransferFromError }; | ||
export type MarketplaceError = { 'Buy' : BuyError } | | ||
{ 'Configuration' : ConfigurationError } | | ||
{ 'Icrc1Transfer' : TransferError } | | ||
{ 'DeferredCanister' : DeferredError } | | ||
{ 'TokenNotFound' : null } | | ||
{ 'FlyCanister' : FlyError } | | ||
{ 'XrcError' : null } | | ||
{ 'StorageError' : null } | | ||
{ 'CanisterCall' : [RejectionCode, string] } | | ||
{ 'Dip721' : NftError } | | ||
{ 'Icrc2Transfer' : TransferFromError }; | ||
export interface MarketplaceInitData { | ||
'deferred_canister' : Principal, | ||
'fly_canister' : Principal, | ||
'admins' : Array<Principal>, | ||
} | ||
export type NftError = { 'UnauthorizedOperator' : null } | | ||
{ 'SelfTransfer' : null } | | ||
{ 'TokenNotFound' : null } | | ||
{ 'UnauthorizedOwner' : null } | | ||
{ 'TxNotFound' : null } | | ||
{ 'SelfApprove' : null } | | ||
{ 'OperatorNotFound' : null } | | ||
{ 'ExistedNFT' : null } | | ||
{ 'OwnerNotFound' : null } | | ||
{ 'Other' : string }; | ||
export type PoolError = { 'PoolNotFound' : bigint } | | ||
{ 'NotEnoughTokens' : null }; | ||
export type RegisterError = { 'TransactionNotFound' : null }; | ||
export type RejectionCode = { 'NoError' : null } | | ||
{ 'CanisterError' : null } | | ||
{ 'SysTransient' : null } | | ||
{ 'DestinationInvalid' : null } | | ||
{ 'Unknown' : null } | | ||
{ 'SysFatal' : null } | | ||
{ 'CanisterReject' : null }; | ||
export type Result = { 'Ok' : null } | | ||
{ 'Err' : MarketplaceError }; | ||
export type Result_1 = { 'Ok' : bigint } | | ||
{ 'Err' : MarketplaceError }; | ||
export type TokenError = { 'ContractAlreadySigned' : bigint } | | ||
{ 'ContractValueIsNotMultipleOfInstallments' : null } | | ||
{ 'TokenAlreadyExists' : bigint } | | ||
{ 'TokensMismatch' : null } | | ||
{ 'ContractAlreadyExists' : bigint } | | ||
{ 'ContractTokensShouldBeEmpty' : null } | | ||
{ 'TokenDoesNotBelongToContract' : bigint } | | ||
{ 'TokenNotFound' : bigint } | | ||
{ 'ContractSellerQuotaIsNot100' : null } | | ||
{ 'ContractNotFound' : bigint } | | ||
{ 'CannotCloseContract' : null } | | ||
{ 'ContractNotSigned' : bigint } | | ||
{ 'ContractHasNoSeller' : null } | | ||
{ 'ContractHasNoTokens' : null } | | ||
{ 'TokenIsBurned' : bigint } | | ||
{ 'BadMintTokenOwner' : bigint } | | ||
{ 'BadContractProperty' : null }; | ||
export type TransferError = { | ||
'GenericError' : { 'message' : string, 'error_code' : bigint } | ||
} | | ||
{ 'TemporarilyUnavailable' : null } | | ||
{ 'BadBurn' : { 'min_burn_amount' : bigint } } | | ||
{ 'Duplicate' : { 'duplicate_of' : bigint } } | | ||
{ 'BadFee' : { 'expected_fee' : bigint } } | | ||
{ 'CreatedInFuture' : { 'ledger_time' : bigint } } | | ||
{ 'TooOld' : null } | | ||
{ 'InsufficientFunds' : { 'balance' : bigint } }; | ||
export type TransferFromError = { | ||
'GenericError' : { 'message' : string, 'error_code' : bigint } | ||
} | | ||
{ 'TemporarilyUnavailable' : null } | | ||
{ 'InsufficientAllowance' : { 'allowance' : bigint } } | | ||
{ 'BadBurn' : { 'min_burn_amount' : bigint } } | | ||
{ 'Duplicate' : { 'duplicate_of' : bigint } } | | ||
{ 'BadFee' : { 'expected_fee' : bigint } } | | ||
{ 'CreatedInFuture' : { 'ledger_time' : bigint } } | | ||
{ 'TooOld' : null } | | ||
{ 'InsufficientFunds' : { 'balance' : bigint } }; | ||
export interface _SERVICE { | ||
'admin_cycles' : ActorMethod<[], bigint>, | ||
'admin_set_admins' : ActorMethod<[Array<Principal>], Result>, | ||
'admin_set_deferred_canister' : ActorMethod<[Principal], undefined>, | ||
'admin_set_fly_canister' : ActorMethod<[Principal], Result>, | ||
'admin_set_interest_rate_for_buyer' : ActorMethod<[number], undefined>, | ||
'buy_token' : ActorMethod<[bigint, [] | [Uint8Array | number[]]], Result>, | ||
'get_token_price_icp' : ActorMethod<[bigint], Result_1>, | ||
} |
Oops, something went wrong.