stellar / js-stellar-base

The lowest-level stellar helper library. It consists of classes to read, write, hash, and sign Stellar xdr
https://stellar.github.io/js-stellar-base/
Apache License 2.0
107 stars 138 forks source link

Add helpful abstractions for common invocation types. #703

Closed Shaptic closed 10 months ago

Shaptic commented 11 months ago

What

This adds four new aliases for Operation to make common versions of Operation.invokeHostFunction easier to create.

/** Returns an operation that invokes a contract function. */
function invokeContractFunction({
  contract: string,
  function: string,
  args: xdr.ScVal[],
  auth?: xdr.SorobanAuthorizationEntry[],
  source?: string
}): xdr.Operation;

/** Returns an operation that creates a custom WASM contract. */
function createCustomContract({
  address: Address,
  wasmHash: Uint8Array | Buffer
  salt?: Uint8Array | Buffer,
  auth?: xdr.SorobanAuthorizationEntry[],
  source?: string
}): xdr.Operation;

/** Returns an operation that wraps a Stellar asset into a token contract. */
function createStellarAssetContract({
  asset: Asset | string,
  auth?: xdr.SorobanAuthorizationEntry[],
  source?: string
}): xdr.Operation;

/** Returns an operation that uploads WASM for a contract. */
function uploadContractWasm({
  wasm: Uint8Array | Buffer,
  auth?: xdr.SorobanAuthorizationEntry,
  source?: string
}): xdr.Operation;

Why

Closes #700 and #697.

github-actions[bot] commented 11 months ago

Size Change: +30 kB (+1%)

Total Size: 3.19 MB

Filename Size Change
dist/stellar-base.js 2.34 MB +22.4 kB (+1%)
dist/stellar-base.min.js 850 kB +7.59 kB (+1%)

compressed-size-action