Skip to content

Commit

Permalink
refactor!: improve all scallop class
Browse files Browse the repository at this point in the history
  • Loading branch information
mr-donor committed Sep 26, 2023
1 parent 59b32a7 commit 5a4df11
Show file tree
Hide file tree
Showing 39 changed files with 3,272 additions and 1,552 deletions.
417 changes: 417 additions & 0 deletions src/builders/coreBuilder.ts

Large diffs are not rendered by default.

30 changes: 30 additions & 0 deletions src/builders/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { TransactionBlock } from '@mysten/sui.js';
import { SuiTxBlock as SuiKitTxBlock } from '@scallop-io/sui-kit';
import { newCoreTxBlock } from './coreBuilder';
import { newSpoolTxBlock } from './spoolBuilder';
import type { ScallopBuilder } from '../models';
import type { ScallopTxBlock } from '../types';

/**
* Create a new ScallopTxBlock instance.
*
* @param builder - Scallop builder instance.
* @param txBlock - Scallop txBlock, txBlock created by SuiKit, or original transaction block.
* @return ScallopTxBlock
*/
export const newScallopTxBlock = (
builder: ScallopBuilder,
initTxBlock?: ScallopTxBlock | SuiKitTxBlock | TransactionBlock
): ScallopTxBlock => {
const spoolTxBlock = newSpoolTxBlock(builder, initTxBlock);
const coreTxBlock = newCoreTxBlock(builder, spoolTxBlock);

return new Proxy(coreTxBlock, {
get: (target, prop) => {
if (prop in spoolTxBlock) {
return Reflect.get(spoolTxBlock, prop);
}
return Reflect.get(target, prop);
},
}) as ScallopTxBlock;
};
Loading

0 comments on commit 5a4df11

Please sign in to comment.