Skip to content

Commit

Permalink
chore: abstractJS
Browse files Browse the repository at this point in the history
  • Loading branch information
joepegler committed Jan 15, 2025
1 parent 89ef704 commit b26c193
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 31 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[![Biconomy](https://img.shields.io/badge/Made_with_%F0%9F%8D%8A_by-Biconomy-ff4e17?style=flat)](https://biconomy.io) [![License MIT](https://img.shields.io/badge/License-MIT-blue?&style=flat)](./LICENSE) [![codecov](https://codecov.io/github/bcnmy/sdk/graph/badge.svg?token=DTdIR5aBDA)](https://codecov.io/github/bcnmy/sdk)

# SDK 🚀
# abstractJS 🚀

[![Open in GitHub Codespaces](https://github.com/codespaces/badge.svg)](https://codespaces.new/bcnmy/sdk)

Expand Down
6 changes: 3 additions & 3 deletions src/sdk/account/decorators/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,11 @@ describe("mee:build", () => {
meeClient = createMeeClient({ account: mcNexus })
})

it("should use the default action while building instructions", async () => {
it("should use the base option while building instructions", async () => {
const instructions = await build(
{ account: mcNexus },
{
type: "default",
type: "base",
data: {
instructions: [
{
Expand Down Expand Up @@ -89,7 +89,7 @@ describe("mee:build", () => {
const instructions = await build(
{ account: mcNexus, currentInstructions },
{
type: "default",
type: "base",
data: {
instructions: [
{
Expand Down
32 changes: 8 additions & 24 deletions src/sdk/account/decorators/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import type { BaseMultichainSmartAccount } from "../toMultiChainNexusAccount"
import type { MultichainContract } from "../utils/getMultichainContract"

Check failure on line 4 in src/sdk/account/decorators/build.ts

View workflow job for this annotation

GitHub Actions / size report

'MultichainContract' is declared but its value is never read.
import {
type BuildBaseInstructionsParams,
buildBaseInstructions
} from "./instructions/buildBaseInstructions"
import { type BuildIntentParams, buildIntent } from "./instructions/buildIntent"
type BuildIntentParams,
buildBaseInstructions,
buildIntent
} from "./instructions"

/**
* Base parameters for building instructions
Expand All @@ -20,27 +21,12 @@ export type BaseInstructionsParams = {
currentInstructions?: Instruction[]
}

/**
* Configuration for bridging tokens between chains
* @property amount - The amount of tokens to bridge
* @property mcToken - The multichain token contract to bridge
* @property chain - The destination chain for the bridge operation
*/
export type BridgeInstructionsForBridgeAction = {
/** The amount of tokens to require */
amount: bigint
/** The token to require */
mcToken: MultichainContract<typeof erc20Abi>
/** The chain to require the token on */
chain: Chain
}

/**
* Default build action which is used to build instructions for a chain
*/
export type BuildBaseInstruction = {
/** The type of action */
type: "default"
type: "base"
/** The parameters for the action */
data: BuildBaseInstructionsParams
}
Expand All @@ -67,7 +53,7 @@ export type BuildInstructionTypes =
* @param params - The build instructions configuration
* @param params.account - {@link BaseMultichainSmartAccount} The multichain smart account to check balances for
* @param params.currentInstructions - {@link Instruction[]} Optional array of existing instructions to append to
* @param params.type - The type of build action ("default" | "intent")
* @param params.type - The type of build action ("base" | "intent")
* @param params.parameters - {@link BuildBaseInstruction} | {@link BuildIntentInstruction}
*
* @returns Promise resolving to an array of {@link Instruction}
Expand All @@ -87,7 +73,7 @@ export type BuildInstructionTypes =
* @example
* // Default action example
* const defaultInstructions = await build({
* type: "default",
* type: "base",
* parameters: myExistingInstruction,
* account: myMultichainAccount
* })
Expand All @@ -96,15 +82,13 @@ export const build = async (
baseParams: BaseInstructionsParams,
parameters: BuildInstructionTypes
): Promise<Instruction[]> => {
console.log({ baseParams, parameters })

const { type, data } = parameters

switch (type) {
case "intent": {
return buildIntent(baseParams, data)
}
case "default": {
case "base": {
return buildBaseInstructions(baseParams, data)
}
default: {
Expand Down
4 changes: 2 additions & 2 deletions src/sdk/clients/createMeeClient.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ describe("mee.createMeeClient", async () => {
// These can be any 'Instruction', or any helper method that resolves to a 'Instruction',
// including 'build'. They all are resolved in the 'getQuote' method under the hood.
const currentInstructions = await meeClient.account.build({
type: "default",
type: "base",
data: {
instructions: [
{
Expand Down Expand Up @@ -187,7 +187,7 @@ describe("mee.createMeeClient", async () => {
}),
// Second instruction: Execute a simple call on the Base network
mcNexus.build({
type: "default",
type: "base",
data: {
instructions: [
{
Expand Down
2 changes: 1 addition & 1 deletion src/sdk/clients/decorators/mee/getQuote.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ describe("mee.getQuote", () => {
}
}),
mcNexus.build({
type: "default",
type: "base",
data: {
instructions: [
{
Expand Down

0 comments on commit b26c193

Please sign in to comment.