Skip to content
This repository has been archived by the owner on Dec 18, 2023. It is now read-only.

Commit

Permalink
Added missing idl file version
Browse files Browse the repository at this point in the history
  • Loading branch information
8dell committed Jun 15, 2022
1 parent 5f6b865 commit eaa30d5
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@mean-dao/msp",
"version": "2.6.0-alpha.2",
"version": "2.6.0-alpha.3",
"description": "MSP Typescript SDK",
"private": false,
"main": "lib/index.js",
Expand Down
2 changes: 2 additions & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ export class Constants {
static SOL_MINT = new PublicKey('11111111111111111111111111111111');
}

export const LATEST_IDL_FILE_VERSION = 1;

export enum WARNING_TYPES {
NO_WARNING = 0,
INVALID_ADDRESS = 1,
Expand Down
26 changes: 25 additions & 1 deletion src/msp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { createProgram, createWrapSolInstructions, getStream, getStreamCached, g
import { Constants, WARNING_TYPES } from "./constants";
import { Beneficiary, listTreasuries, StreamBeneficiary } from ".";
import { u64Number } from "./u64n";
import { LATEST_IDL_FILE_VERSION } from "./constants"

/**
* API class with functions to interact with the Money Streaming Program using Solana Web3 JS API
Expand Down Expand Up @@ -191,7 +192,6 @@ export class MSP {
mint: PublicKey,
amount: number,
): Promise<Transaction> {
let txSigners: Signer[] = [];
let ixs: TransactionInstruction[] = [];

if (mint.equals(Constants.SOL_MINT)) {
Expand Down Expand Up @@ -344,6 +344,7 @@ export class MSP {
// Create treasury
ixs.push(
this.program.instruction.createTreasury(
LATEST_IDL_FILE_VERSION,
new BN(slot),
streamName ?? "",
TreasuryType.Open,
Expand Down Expand Up @@ -403,6 +404,7 @@ export class MSP {
// Add Funds
ixs.push(
this.program.instruction.addFunds(
LATEST_IDL_FILE_VERSION,
new BN(amount),
{
accounts: {
Expand Down Expand Up @@ -433,6 +435,7 @@ export class MSP {
// Create Stream
ixs.push(
this.program.instruction.createStream(
LATEST_IDL_FILE_VERSION,
streamName ?? "",
new BN(startUtcInSeconds),
new BN(0), // rate amount units
Expand Down Expand Up @@ -545,6 +548,7 @@ export class MSP {
// Create treasury
ixs.push(
this.program.instruction.createTreasury(
LATEST_IDL_FILE_VERSION,
new BN(slot),
streamName,
TreasuryType.Open,
Expand Down Expand Up @@ -591,6 +595,7 @@ export class MSP {
// Add Funds
ixs.push(
this.program.instruction.addFunds(
LATEST_IDL_FILE_VERSION,
new BN(allocationAssigned),
{
accounts: {
Expand Down Expand Up @@ -620,6 +625,7 @@ export class MSP {
// Create Stream
ixs.push(
this.program.instruction.createStream(
LATEST_IDL_FILE_VERSION,
streamName,
new BN(startUtcInSeconds),
new BN(rateAmount ?? 0), // rate amount units
Expand Down Expand Up @@ -697,6 +703,7 @@ export class MSP {
);

let tx = this.program.transaction.createTreasury(
LATEST_IDL_FILE_VERSION,
new BN(slot),
label,
type,
Expand Down Expand Up @@ -820,6 +827,7 @@ export class MSP {

// Create Stream
let tx = this.program.transaction.createStream(
LATEST_IDL_FILE_VERSION,
streamName,
new BN(startUtcInSeconds),
new BN(rateAmount as number),
Expand Down Expand Up @@ -926,6 +934,7 @@ export class MSP {

let streamAccount = Keypair.generate();
let ix = this.program.instruction.createStream(
LATEST_IDL_FILE_VERSION,
beneficiary.streamName,
new BN(startUtcInSeconds),
new BN(rateAmount as number),
Expand Down Expand Up @@ -1049,6 +1058,7 @@ export class MSP {

ixs.push(
this.program.instruction.addFunds(
LATEST_IDL_FILE_VERSION,
new BN(amount),
{
accounts: {
Expand Down Expand Up @@ -1084,6 +1094,7 @@ export class MSP {

ixs.push(
this.program.instruction.allocate(
LATEST_IDL_FILE_VERSION,
allocationAmountBn,
{
accounts: {
Expand Down Expand Up @@ -1191,6 +1202,7 @@ export class MSP {

ixs.push(
this.program.instruction.addFunds(
LATEST_IDL_FILE_VERSION,
new BN(amount),
{
accounts: {
Expand Down Expand Up @@ -1277,6 +1289,7 @@ export class MSP {
);

let tx = this.program.transaction.allocate(
LATEST_IDL_FILE_VERSION,
new BN(amount),
{
accounts: {
Expand Down Expand Up @@ -1360,6 +1373,7 @@ export class MSP {
const txSigners: Signer[] = [];

let withdrawIx = this.program.instruction.withdraw(
LATEST_IDL_FILE_VERSION,
new BN(amount),
{
accounts: {
Expand Down Expand Up @@ -1429,6 +1443,7 @@ export class MSP {
const associatedToken = new PublicKey(streamInfo.associatedToken as string);

let tx = this.program.transaction.pauseStream(
LATEST_IDL_FILE_VERSION,
{
accounts: {
initializer: treasurer, // TODO: payer = payer, inititlizer = treasurer (change initializer to treasurer in MSP)
Expand Down Expand Up @@ -1469,6 +1484,7 @@ export class MSP {
const associatedToken = new PublicKey(streamInfo.associatedToken as string);

let tx = this.program.transaction.resumeStream(
LATEST_IDL_FILE_VERSION,
{
accounts: {
initializer: treasurer, // TODO: payer = payer, inititlizer = treasurer (change initializer to treasurer in MSP)
Expand Down Expand Up @@ -1541,6 +1557,7 @@ export class MSP {

let ixs: TransactionInstruction[] = [
this.program.instruction.closeStream(
LATEST_IDL_FILE_VERSION,
{
accounts: {
payer: payer,
Expand Down Expand Up @@ -1583,6 +1600,7 @@ export class MSP {

ixs.push(
this.program.instruction.closeTreasury(
LATEST_IDL_FILE_VERSION,
{
accounts: {
payer: payer,
Expand Down Expand Up @@ -1689,6 +1707,7 @@ export class MSP {
const txSigners: Signer[] = [];

let closeTreasuryIx = this.program.instruction.closeTreasury(
LATEST_IDL_FILE_VERSION,
{
accounts: {
payer: payer,
Expand Down Expand Up @@ -1766,6 +1785,7 @@ export class MSP {
const totalStreams = (await this.program.account.stream.all(memcmpFilters)).length;

let tx = this.program.transaction.refreshTreasuryData(
LATEST_IDL_FILE_VERSION,
new BN(totalStreams),
{
accounts: {
Expand Down Expand Up @@ -1804,6 +1824,7 @@ export class MSP {
}

let tx = this.program.transaction.transferStream(
LATEST_IDL_FILE_VERSION,
newBeneficiary,
{
accounts: {
Expand Down Expand Up @@ -1878,6 +1899,7 @@ export class MSP {

// Create Stream
let tx = this.program.transaction.createStream(
LATEST_IDL_FILE_VERSION,
streamName,
new BN(startUtcInSeconds),
new BN(rateAmount as number),
Expand Down Expand Up @@ -1980,6 +2002,7 @@ export class MSP {
if (streamBeneficiary.address.toBase58() === treasurer.toBase58()) { continue; }

let ix = this.program.instruction.createStream(
LATEST_IDL_FILE_VERSION,
streamBeneficiary.streamName,
new BN(startUtcInSeconds),
new BN(rateAmount as number),
Expand Down Expand Up @@ -2067,6 +2090,7 @@ export class MSP {
const txSigners: Signer[] = [];

let treasuryWithdrawIx = this.program.instruction.treasuryWithdraw(
LATEST_IDL_FILE_VERSION,
new BN(amount),
{
accounts: {
Expand Down
6 changes: 4 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import { BN, BorshInstructionCoder, Idl, Program } from "@project-serum/anchor";
/**
* MSP
*/
import { Constants } from "./constants";
import { Constants, LATEST_IDL_FILE_VERSION } from "./constants";
import { StreamActivity, Stream, MSP_ACTIONS, TransactionFees, StreamActivityRaw } from "./types";
import { STREAM_STATUS, Treasury, TreasuryType } from "./types";
import { IDL, Msp } from './msp_idl_001'; // point to the latest IDL
Expand Down Expand Up @@ -70,7 +70,9 @@ export const getStream = async (

try {

const streamEventResponse = await program.simulate.getStream({
const streamEventResponse = await program.simulate.getStream(
LATEST_IDL_FILE_VERSION,
{
accounts: {
stream: address
}
Expand Down

0 comments on commit eaa30d5

Please sign in to comment.