Class: Cubist
This class is the way to work with interface with your cubist projects. This class abstracts over all contracts and contract factories.
Example
Create a new project to access contracts and their factories:
const cubist = new Cubist();
// get contract factory
const Receiver = cubist.getContractFactory('Receiver');
// deploy Receiver, ...
// get already deployed Sender contract
const senderInstance = cubist.getContract('Sender');
// wait for bridge to spin up
assert(await cubist.whenBridged());
Beyond exposing project contracts (via getContract) and contract factories (via getContractFactory), projects can wait for bridges (between contracts and cross-chain shims they call) to start up with whenBridged.
At build time, cubist build
generates a CubistORM class that extends
Cubist with the project-specific factories (see
Overview). This means, in practice, you don't even need to use
getContract and getContractFactory.
Example
Create a new project to access contracts and their factories with CubistORM:
import { CubistORM, } from '../build/orm/index.js';
const cubist = new CubistORM();
// get contract factory
const Receiver = cubist.Receiver;
// deploy Receiver, ...
// get already deployed Sender contract
const senderInstance = cubist.Sender.attach();
// wait for bridge to spin up
assert(await cubist.whenBridged());
Exports
Constructors
Properties
Methods
Constructors
constructor
• new Cubist(config?
)
Create new project. The constructor looks for the nearest
cubist-config.json
, i.e., it looks in the current directory and every
parent directory until it finds the config.
If the code using this SDK is not in the same directory tree, though, you can pass an explicit config:
const config = new Config('/path/to/your/cubist-config.json');
const cubist = new Cubist (config);
In the future this argument might change, e.g., to a filename instead of explicit Config.
Parameters
Name | Type | Description |
---|---|---|
config? | Config | Optional config (using near otherwise). |
Defined in
submodules/cubist-node-sdk/src/cubist.ts:199
Properties
config
• Readonly
config: Config
Underlying configuration.
Defined in
submodules/cubist-node-sdk/src/cubist.ts:172
Methods
getContract
▸ getContract<T
>(name
, addr?
, ignoreReceipt?
): Contract
<T
>
Get an existing deployed contract. This method looks up the contract's
deploy receipts in the deploy
directory unless you explicitly tell it to
ignoreReceipt
s (e.g., because you're trying to get a contract deployed
with another tool).
For now we only support deploying a contract once so calling
getContract
with the same name but different addresses is not yet
supported.
Throws
If the contract could not be found, if there are multiple contracts and the address argument is omitted, or if the receipt is missing (unless ignoreReceipt is set).
Type parameters
Name | Type |
---|---|
T | extends Contract <T > |
Parameters
Name | Type | Default value | Description |
---|---|---|---|
name | string | undefined | The contract name. |
addr? | string | undefined | Optional contract address (if more than one contract with same name). |
ignoreReceipt | boolean | false | Ignore receipt (e.g., if contract deployed with another tool). |
Returns
Contract
<T
>
The contract.
Defined in
submodules/cubist-node-sdk/src/cubist.ts:305
getContractFactory
▸ getContractFactory<T
>(name
): ContractFactory
<T
>
Get contract factory given the contract name.
Type parameters
Name | Type |
---|---|
T | extends Contract <T > |
Parameters
Name | Type | Description |
---|---|---|
name | string | The contract name. |
Returns
The contract factory.
Defined in
submodules/cubist-node-sdk/src/cubist.ts:259
whenBridged
▸ whenBridged(retries?
, delayMs?
): Promise
<boolean
>
Returns a promise that completes once bridges have been established for all contracts in this projects.
Throws
if any contract in this project has not been deployed
Parameters
Name | Type | Default value | Description |
---|---|---|---|
retries | number | 100 | how many times to check |
delayMs | number | 100 | delay in milliseconds between checks |
Returns
Promise
<boolean
>
- true if all bridges have been established