Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion studio-backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"main": "index.ts",
"license": "MIT",
"dependencies": {
"@mysten/sui.js": "^0.17.1",
"@mysten/sui.js": "^0.30.0",
"@types/cors": "^2.8.12",
"@types/express": "^4.17.14",
"@types/node": "^18.11.9",
Expand Down
45 changes: 2 additions & 43 deletions studio-backend/src/compile.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export async function compile(project: Project): Promise<string | string[]> {
version = "0.0.1"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework", rev = "devnet" }
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "testnet" }

[addresses]
${addresses}
Expand Down Expand Up @@ -135,7 +135,7 @@ export async function test(project: Project): Promise<TestReturn> {
version = "0.0.1"

[dependencies]
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework", rev = "devnet" }
Sui = { git = "https://github.com/MystenLabs/sui.git", subdir = "crates/sui-framework/packages/sui-framework", rev = "testnet" }

[addresses]
${addresses}
Expand Down Expand Up @@ -232,46 +232,5 @@ export async function test(project: Project): Promise<TestReturn> {
}
}

export async function publish (compiledModules: string[]) {
dotenv.config();
if (process.env.RECOVERY_PHRASE === undefined) {
throw new Error('RECOVERY_PHRASE is not defined');
}
// connect to local RPC server
const provider = new JsonRpcProvider();
const keyPair = Ed25519Keypair.deriveKeypair(process.env.RECOVERY_PHRASE)
const signer = new RawSigner(keyPair, provider);
// await provider.requestSuiFromFaucet(
// await signer.getAddress()
// );
console.log(`Signer address: ${await signer.getAddress()}`);

// publish the compiled modules

try {
// const publishTxn = await signer.publish({
// compiledModules: compiledModules,
// gasBudget: 10000,
// });
// console.log(publishTxn)

const publishTxn = await signer.signAndExecuteTransaction({
kind: 'publish',
data: {
compiledModules: compiledModules,
gasBudget: 10000
},
});

console.log(publishTxn);

return publishTxn;
} catch (error: any) {
console.log(error);
}


}



15 changes: 1 addition & 14 deletions studio-backend/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import cors from 'cors';
import express from 'express';
import { compile, publish, test } from './compile';
import { compile, test } from './compile';
import { getObjectDetails, getPackageDetails } from './object-details';

const app = express();
Expand Down Expand Up @@ -76,19 +76,6 @@ app.post('/test', async (req, res) => {

});

app.post('/publish', async (req, res) => {
const compiledModules = req.body.compiledModules;

// console.log(compiledModules);
console.log('publishing modules...')

// Call compile function
const compileResult = await publish(compiledModules);

res.send(compileResult);

});

app.post('/object-details', async (req, res) => {
const objectId = req.body.objectId as string;
const rpc = req.body.rpc as string;
Expand Down
39 changes: 31 additions & 8 deletions studio-backend/src/object-details.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,43 @@
import { JsonRpcProvider } from "@mysten/sui.js";
import { JsonRpcProvider, Connection } from "@mysten/sui.js";


export async function getObjectDetails(objectId: string, rpc?: string) {
const provider = new JsonRpcProvider(rpc);
const objectDetails = await provider.getObject(objectId);
let provider;
if (rpc) {
const connection = new Connection({
fullnode: rpc,
});
provider = new JsonRpcProvider(connection);
} else {
provider = new JsonRpcProvider();
}

const objectDetails = await provider.getObject({
id: objectId,
options: {
showContent: true,
showDisplay: true,
}
});

return objectDetails;
}

export async function getPackageDetails(packageId: string, rpc?: string) {
console.log('1')
const provider = new JsonRpcProvider(rpc);
let provider;
if (rpc) {
const connection = new Connection({
fullnode: rpc,
});
provider = new JsonRpcProvider(connection);
} else {
provider = new JsonRpcProvider();
}
// console.log('provider', provider)
console.log('2')
const packageDetails = await provider.getNormalizedMoveModulesByPackage(packageId);
console.log('packageDetails', packageDetails)
console.log('3')
const packageDetails = await provider.getNormalizedMoveModulesByPackage({
package: packageId,
});

return packageDetails;
}
Loading