
Research
/Security News
737 Chrome VPN Extensions Linked to Brand Impersonation and Browser Traffic Redirection
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.
@fluxfi/codegen
Advanced tools
⚠️ Warning: This package is currently in development and may have breaking changes.
To use this package you will need to install it from npm:
pnpm install @fluxfi/codegen
Then create a sui-codegen.config.ts to define what packages you want to generate code for:
import type { SuiCodegenConfig } from './src/config.js';
const config: SuiCodegenConfig = {
output: './src/generated',
generateSummaries: true,
prune: true,
packages: [
{
package: '@your-scope/your-package',
path: './move/your-package',
},
],
};
export default config;
The package field should be the MVR name for your move package. If you have not registered your
package on MVR yet, you can use the @local-pkg scope, and set up an override in your
SuiGrpcClient to resolve it to the correct address.
To generate code, you will first need to create package_summaries for your package. You can do
this by running the following command in the root of you move package:
sui move summary
this will create a new package_summaries directory (which can be added to .gitignore) for the
codegen tool to analyze when generating code for your package.
If you are having trouble with this command, ensure you are using the latest version of the sui cli
(version 1.51.1 or later).
Now that you have the package_summaries you can generate you typescript code, by running
pnpm sui-ts-codegen generate
or by adding something the following script to your package.json and running pnpm codegen
{
"scripts": {
"codegen": "sui-ts-codegen generate"
}
}
If your package is registered on MVR, the generated code should work without additional
configuration. If you are using a @local-pkg name, you will need to configure your SuiGrpcClient
to resolve the package name correctly:
import { SuiGrpcClient } from '@fluxfi/sui/grpc';
const client = new SuiGrpcClient({
network: 'testnet',
baseUrl: 'https://fullnode.testnet.sui.io:443',
mvr: {
overrides: {
packages: {
'@local-pkg/your-package': YOUR_PACKAGE_ID,
},
},
},
});
If you are using dapp-kit-core, you can configure package overrides when creating your dApp Kit
instance:
import { createDAppKit } from '@fluxfi/dapp-kit-core';
import { SuiGrpcClient } from '@fluxfi/sui/grpc';
const GRPC_URLS = {
testnet: 'https://fullnode.testnet.sui.io:443',
};
const PACKAGE_IDS = {
testnet: {
yourPackage: YOUR_TESTNET_PACKAGE_ID,
},
};
const dAppKit = createDAppKit({
networks: ['testnet'],
createClient: (network) => {
return new SuiGrpcClient({
network,
baseUrl: GRPC_URLS[network],
mvr: {
overrides: {
packages: {
'@local-pkg/your-package': PACKAGE_IDS[network].yourPackage,
},
},
},
});
},
});
The generated code provides type-safe functions for calling Move functions. Here's how to use them:
To create new objects from your Move package, use the generated create function:
This example assumes a simple counter package based on the create-dapp template:
import { Transaction } from '@fluxfi/sui/transactions';
import * as counter from './generated/counter/counter';
async function createCounter() {
// create a new Transaction
const tx = new Transaction();
// Add a create call
tx.add(counter.create());
const { digest } = suiClient.signAndExecuteTransaction({
transaction: tx,
signer: keypair,
});
return digest;
}
async function incrementCount(id: string) {
const tx = tx.add(
counter.increment({
// Arguments can be passed in by name as an object, or as an array of values
arguments: {
// Argument values can be js primitives, or use methods like tx.pure or tx.object, or results of other move calls
counter: id,
},
}),
);
const { digest } = suiClient.signAndExecuteTransaction({
transaction: tx,
signer: keypair,
});
return digest;
}
The generated code also provides BCS definitions for your Move types:
First, you will need to load the bcs data for your object, then parse it with your generated type:
import * as counter from './generated/counter/counter';
async await function readCounter(id: string) {
const data = suiClient.getObject({
id,
options: {
// request the bcs data when loading your object
showBcs: true,
}
})
if (data.data.bcs?.dataType !== 'moveObject') {
throw new Error('Expected a move object')
}
return counter.Counter.fromBase64(data.data.bcs.bcsBytes)
}
FAQs
typescript codegen for sui move
We found that @fluxfi/codegen demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
The campaign amassed more than 75,000 installs by targeting Russian-speaking users seeking access to blocked services.

Company News
Open source maintainers are under more pressure than ever. We're raising our open source program from the Team plan to the Business plan, free.

Security News
The supply chain control that delays freshly published gems now covers lockfile generation and gem vendoring in Ruby projects.