@mysten/walrus 1.0.2 → 1.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,21 @@
1
1
  # @mysten/walrus
2
2
 
3
+ ## 1.0.4
4
+
5
+ ### Patch Changes
6
+
7
+ - 43e69f8: Add embedded LLM-friendly docs to published packages
8
+ - Updated dependencies [43e69f8]
9
+ - Updated dependencies [e51dc5d]
10
+ - @mysten/bcs@2.0.3
11
+ - @mysten/sui@2.8.0
12
+
13
+ ## 1.0.3
14
+
15
+ ### Patch Changes
16
+
17
+ - 3d53583: Improve typing of generated bcs tuples
18
+
3
19
  ## 1.0.2
4
20
 
5
21
  ### Patch Changes
package/dist/client.d.mts CHANGED
@@ -99,24 +99,24 @@ declare class WalrusClient {
99
99
  active_set: {
100
100
  id: string;
101
101
  };
102
- next_committee: {
102
+ next_committee: [{
103
103
  contents: {
104
104
  key: string;
105
105
  value: number[];
106
106
  }[];
107
- }[] | null;
108
- committee: {
107
+ }] | null;
108
+ committee: [{
109
109
  contents: {
110
110
  key: string;
111
111
  value: number[];
112
112
  }[];
113
- }[];
114
- previous_committee: {
113
+ }];
114
+ previous_committee: [{
115
115
  contents: {
116
116
  key: string;
117
117
  value: number[];
118
118
  }[];
119
- }[];
119
+ }];
120
120
  next_epoch_params: {
121
121
  total_capacity_size: string;
122
122
  storage_price_per_unit_size: string;
@@ -1 +1 @@
1
- {"version":3,"file":"client.d.mts","names":[],"sources":["../src/client.ts"],"sourcesContent":[],"mappings":";;;;;;;;;;;iBA8HgB;;;;IAIb,cAAc;;EAJD,QAAA,EAAM,CAAA,MAAA,EAOD,iBAPC,EAAA,GAOgB,YAPhB;CACrB;AACA,cA6BY,YAAA,CA7BZ;EAEgB,CAAA,OAAA;EAAd,WAAA,CAAA,MAAA,EA2CkB,kBA3ClB;;EAGkB,WAAA,CAAA,CAAA,EAAA,MAAA,GAoGT,OApGS,CAAA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;;;mBAyBT,aAAU;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAyDqB,4BAAyB;;;;;;;;;;;;;;;KA8C5E,iCAA8B,SAAA,mBAAA;;;;;;;;;kCA2CK,gCAAgC;;iBAExD;;;;;;;;;;;;;;;;;KA2BX,0BAAuB,QAAA,mBAAA;;;;;;;;;;;;;;;;;KAiCvB,mBAAgB;;;;;;;;;;;;;;;;;;;;;KAqGqB,oBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gBAkC7C;;aAEH;;MAER;;;;;;;;;;;;;;;;;;;;;;;;;MA4G2C,QAAA;;;;;MAWH,QAAA;;;;KA+CD,oBAAiB;;;;;;;;;;;;;;;;;;;;;KAmB/B,wBAAwB;;;KAqM1B,uBAAuB"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":["val"],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import {\n\tbcs,\n\tBcsType,\n\tTypeTag,\n\tTypeTagSerializer,\n\tBcsStruct,\n\tBcsEnum,\n\tBcsTuple,\n} from '@mysten/sui/bcs';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\nimport { TransactionArgument, isArgument } from '@mysten/sui/transactions';\nimport { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport interface GetOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> extends SuiClientTypes.GetObjectOptions<Include> {\n\tclient: ClientWithCoreApi;\n}\n\nexport interface GetManyOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> extends SuiClientTypes.GetObjectsOptions<Include> {\n\tclient: ClientWithCoreApi;\n}\n\nexport function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {\n\tconst parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(structTag.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst type = getPureBcsSchema(structTag.typeParams[0]);\n\t\t\t\treturn type ? bcs.option(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tpkg === SUI_FRAMEWORK_ADDRESS &&\n\t\t\tstructTag.module === 'object' &&\n\t\t\t(structTag.name === 'ID' || structTag.name === 'UID')\n\t\t) {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: readonly (string | null)[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new Error(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const [i, argType] of argTypes.entries()) {\n\t\tif (argType === '0x2::clock::Clock') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::random::Random') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::deny_list::DenyList') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x3::sui_system::SuiSystemState') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new Error(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg === undefined) {\n\t\t\t\tthrow new Error(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst type = argTypes[i];\n\t\tconst bcsType = type === null ? null : getPureBcsSchema(type);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t} else if (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new Error(`Invalid argument ${stringify(arg)} for type ${type}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {\n\tasync get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tobjectId,\n\t\t...options\n\t}: GetOptions<Include>): Promise<\n\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t}\n\t> {\n\t\tconst [res] = await this.getMany<Include>({\n\t\t\t...options,\n\t\t\tobjectIds: [objectId],\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tasync getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tclient,\n\t\t...options\n\t}: GetManyOptions<Include>): Promise<\n\t\tArray<\n\t\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t\t}\n\t\t>\n\t> {\n\t\tconst response = (await client.core.getObjects({\n\t\t\t...options,\n\t\t\tinclude: {\n\t\t\t\t...options.include,\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t})) as SuiClientTypes.GetObjectsResponse<Include & { content: true }>;\n\n\t\treturn response.objects.map((obj) => {\n\t\t\tif (obj instanceof Error) {\n\t\t\t\tthrow obj;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...obj,\n\t\t\t\tjson: this.parse(obj.content),\n\t\t\t};\n\t\t});\n\t}\n}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {}\n\nexport class MoveTuple<\n\tT extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (val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B;CAC5B,MAAM,IAAiF,EACtF,UACA,GAAG,WAKF;EACD,MAAM,CAAC,OAAO,MAAM,KAAK,QAAiB;GACzC,GAAG;GACH,WAAW,CAAC,SAAS;GACrB,CAAC;AAEF,SAAO;;CAGR,MAAM,QAAqF,EAC1F,QACA,GAAG,WAOF;AASD,UARkB,MAAM,OAAO,KAAK,WAAW;GAC9C,GAAG;GACH,SAAS;IACR,GAAG,QAAQ;IACX,SAAS;IACT;GACD,CAAC,EAEc,QAAQ,KAAK,QAAQ;AACpC,OAAI,eAAe,MAClB,OAAM;AAGP,UAAO;IACN,GAAG;IACH,MAAM,KAAK,MAAM,IAAI,QAAQ;IAC7B;IACA;;;AAIJ,IAAa,WAAb,cAGU,QAAiB;AAE3B,IAAa,YAAb,cAGU,SAAkB;AAE5B,SAAS,UAAU,KAAc;AAChC,KAAI,OAAO,QAAQ,SAClB,QAAO,KAAK,UAAU,MAAM,UAAiBA,MAAI;AAElD,KAAI,OAAO,QAAQ,SAClB,QAAO,IAAI,UAAU;AAGtB,QAAO"}
1
+ {"version":3,"file":"index.mjs","names":["val"],"sources":["../../../src/contracts/utils/index.ts"],"sourcesContent":["import {\n\tbcs,\n\tBcsType,\n\tTypeTag,\n\tTypeTagSerializer,\n\tBcsStruct,\n\tBcsEnum,\n\tBcsTuple,\n} from '@mysten/sui/bcs';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\nimport { TransactionArgument, isArgument } from '@mysten/sui/transactions';\nimport { ClientWithCoreApi, SuiClientTypes } from '@mysten/sui/client';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\n\nexport interface GetOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> extends SuiClientTypes.GetObjectOptions<Include> {\n\tclient: ClientWithCoreApi;\n}\n\nexport interface GetManyOptions<\n\tInclude extends Omit<SuiClientTypes.ObjectInclude, 'content'> = {},\n> extends SuiClientTypes.GetObjectsOptions<Include> {\n\tclient: ClientWithCoreApi;\n}\n\nexport function getPureBcsSchema(typeTag: string | TypeTag): BcsType<any> | null {\n\tconst parsedTag = typeof typeTag === 'string' ? TypeTagSerializer.parseFromStr(typeTag) : typeTag;\n\n\tif ('u8' in parsedTag) {\n\t\treturn bcs.U8;\n\t} else if ('u16' in parsedTag) {\n\t\treturn bcs.U16;\n\t} else if ('u32' in parsedTag) {\n\t\treturn bcs.U32;\n\t} else if ('u64' in parsedTag) {\n\t\treturn bcs.U64;\n\t} else if ('u128' in parsedTag) {\n\t\treturn bcs.U128;\n\t} else if ('u256' in parsedTag) {\n\t\treturn bcs.U256;\n\t} else if ('address' in parsedTag) {\n\t\treturn bcs.Address;\n\t} else if ('bool' in parsedTag) {\n\t\treturn bcs.Bool;\n\t} else if ('vector' in parsedTag) {\n\t\tconst type = getPureBcsSchema(parsedTag.vector);\n\t\treturn type ? bcs.vector(type) : null;\n\t} else if ('struct' in parsedTag) {\n\t\tconst structTag = parsedTag.struct;\n\t\tconst pkg = normalizeSuiAddress(structTag.address);\n\n\t\tif (pkg === MOVE_STDLIB_ADDRESS) {\n\t\t\tif (\n\t\t\t\t(structTag.module === 'ascii' || structTag.module === 'string') &&\n\t\t\t\tstructTag.name === 'String'\n\t\t\t) {\n\t\t\t\treturn bcs.String;\n\t\t\t}\n\n\t\t\tif (structTag.module === 'option' && structTag.name === 'Option') {\n\t\t\t\tconst type = getPureBcsSchema(structTag.typeParams[0]);\n\t\t\t\treturn type ? bcs.option(type) : null;\n\t\t\t}\n\t\t}\n\n\t\tif (\n\t\t\tpkg === SUI_FRAMEWORK_ADDRESS &&\n\t\t\tstructTag.module === 'object' &&\n\t\t\t(structTag.name === 'ID' || structTag.name === 'UID')\n\t\t) {\n\t\t\treturn bcs.Address;\n\t\t}\n\t}\n\n\treturn null;\n}\n\nexport function normalizeMoveArguments(\n\targs: unknown[] | object,\n\targTypes: readonly (string | null)[],\n\tparameterNames?: string[],\n) {\n\tconst argLen = Array.isArray(args) ? args.length : Object.keys(args).length;\n\tif (parameterNames && argLen !== parameterNames.length) {\n\t\tthrow new Error(\n\t\t\t`Invalid number of arguments, expected ${parameterNames.length}, got ${argLen}`,\n\t\t);\n\t}\n\n\tconst normalizedArgs: TransactionArgument[] = [];\n\n\tlet index = 0;\n\tfor (const [i, argType] of argTypes.entries()) {\n\t\tif (argType === '0x2::clock::Clock') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::random::Random') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x2::deny_list::DenyList') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === '0x3::sui_system::SuiSystemState') {\n\t\t\tnormalizedArgs.push((tx) => tx.object.system());\n\t\t\tcontinue;\n\t\t}\n\n\t\tlet arg;\n\t\tif (Array.isArray(args)) {\n\t\t\tif (index >= args.length) {\n\t\t\t\tthrow new Error(\n\t\t\t\t\t`Invalid number of arguments, expected at least ${index + 1}, got ${args.length}`,\n\t\t\t\t);\n\t\t\t}\n\t\t\targ = args[index];\n\t\t} else {\n\t\t\tif (!parameterNames) {\n\t\t\t\tthrow new Error(`Expected arguments to be passed as an array`);\n\t\t\t}\n\t\t\tconst name = parameterNames[index];\n\t\t\targ = args[name as keyof typeof args];\n\n\t\t\tif (arg === undefined) {\n\t\t\t\tthrow new Error(`Parameter ${name} is required`);\n\t\t\t}\n\t\t}\n\n\t\tindex += 1;\n\n\t\tif (typeof arg === 'function' || isArgument(arg)) {\n\t\t\tnormalizedArgs.push(arg as TransactionArgument);\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst type = argTypes[i];\n\t\tconst bcsType = type === null ? null : getPureBcsSchema(type);\n\n\t\tif (bcsType) {\n\t\t\tconst bytes = bcsType.serialize(arg as never);\n\t\t\tnormalizedArgs.push((tx) => tx.pure(bytes));\n\t\t\tcontinue;\n\t\t} else if (typeof arg === 'string') {\n\t\t\tnormalizedArgs.push((tx) => tx.object(arg));\n\t\t\tcontinue;\n\t\t}\n\n\t\tthrow new Error(`Invalid argument ${stringify(arg)} for type ${type}`);\n\t}\n\n\treturn normalizedArgs;\n}\n\nexport class MoveStruct<\n\tT extends Record<string, BcsType<any>>,\n\tconst Name extends string = string,\n> extends BcsStruct<T, Name> {\n\tasync get<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tobjectId,\n\t\t...options\n\t}: GetOptions<Include>): Promise<\n\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t}\n\t> {\n\t\tconst [res] = await this.getMany<Include>({\n\t\t\t...options,\n\t\t\tobjectIds: [objectId],\n\t\t});\n\n\t\treturn res;\n\t}\n\n\tasync getMany<Include extends Omit<SuiClientTypes.ObjectInclude, 'content' | 'json'> = {}>({\n\t\tclient,\n\t\t...options\n\t}: GetManyOptions<Include>): Promise<\n\t\tArray<\n\t\t\tSuiClientTypes.Object<Include & { content: true; json: true }> & {\n\t\t\t\tjson: BcsStruct<T>['$inferType'];\n\t\t\t}\n\t\t>\n\t> {\n\t\tconst response = (await client.core.getObjects({\n\t\t\t...options,\n\t\t\tinclude: {\n\t\t\t\t...options.include,\n\t\t\t\tcontent: true,\n\t\t\t},\n\t\t})) as SuiClientTypes.GetObjectsResponse<Include & { content: true }>;\n\n\t\treturn response.objects.map((obj) => {\n\t\t\tif (obj instanceof Error) {\n\t\t\t\tthrow obj;\n\t\t\t}\n\n\t\t\treturn {\n\t\t\t\t...obj,\n\t\t\t\tjson: this.parse(obj.content),\n\t\t\t};\n\t\t});\n\t}\n}\n\nexport class MoveEnum<\n\tT extends Record<string, BcsType<any> | null>,\n\tconst Name extends string,\n> extends BcsEnum<T, Name> {}\n\nexport class MoveTuple<\n\tconst T extends readonly BcsType<any>[],\n\tconst Name extends string,\n> extends BcsTuple<T, Name> {}\n\nfunction stringify(val: unknown) {\n\tif (typeof val === 'object') {\n\t\treturn JSON.stringify(val, (val: unknown) => val);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],"mappings":";;;;;AAaA,MAAM,sBAAsB,oBAAoB,MAAM;AACtD,MAAM,wBAAwB,oBAAoB,MAAM;AAgBxD,SAAgB,iBAAiB,SAAgD;CAChF,MAAM,YAAY,OAAO,YAAY,WAAW,kBAAkB,aAAa,QAAQ,GAAG;AAE1F,KAAI,QAAQ,UACX,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,SAAS,UACnB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,aAAa,UACvB,QAAO,IAAI;UACD,UAAU,UACpB,QAAO,IAAI;UACD,YAAY,WAAW;EACjC,MAAM,OAAO,iBAAiB,UAAU,OAAO;AAC/C,SAAO,OAAO,IAAI,OAAO,KAAK,GAAG;YACvB,YAAY,WAAW;EACjC,MAAM,YAAY,UAAU;EAC5B,MAAM,MAAM,oBAAoB,UAAU,QAAQ;AAElD,MAAI,QAAQ,qBAAqB;AAChC,QACE,UAAU,WAAW,WAAW,UAAU,WAAW,aACtD,UAAU,SAAS,SAEnB,QAAO,IAAI;AAGZ,OAAI,UAAU,WAAW,YAAY,UAAU,SAAS,UAAU;IACjE,MAAM,OAAO,iBAAiB,UAAU,WAAW,GAAG;AACtD,WAAO,OAAO,IAAI,OAAO,KAAK,GAAG;;;AAInC,MACC,QAAQ,yBACR,UAAU,WAAW,aACpB,UAAU,SAAS,QAAQ,UAAU,SAAS,OAE/C,QAAO,IAAI;;AAIb,QAAO;;AAGR,SAAgB,uBACf,MACA,UACA,gBACC;CACD,MAAM,SAAS,M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8B,iBAAA;;cAG9B,gBAAA,SAAyB,KAAA"}
1
+ {"version":3,"file":"error.d.mts","names":[],"sources":["../src/error.ts"],"sourcesContent":[],"mappings":";cAGa,iBAAA,SAA0B,KAAA;AAE1B,cAAA,0BAAA,SAAmC,iBAAA,CAAiB;AAMjE;AAGa,cANA,yBAAA,SAAkC,iBAAA,CAME;AAMjD;AAGa,cAZA,iCAAA,SAA0C,iBAAA,CAYgB;AAMvE;AAGa,cAlBA,2BAAA,SAAoC,0BAAA,CAkBN;;cAf9B,6BAAA,SAAsC,0BAAA;;cAGtC,+BAAA,SAAwC,0BAAA;;cAGxC,uBAAA,SAAgC,0BAAA;;cAGhC,qBAAA,SAA8B,0BAAA;;cAG9B,qBAAA,SAA8B,iBAAA;;cAG9B,gBAAA,SAAyB,KAAA"}
package/docs/index.md ADDED
@@ -0,0 +1,521 @@
1
+ # Walrus SDK
2
+
3
+ > Store and retrieve blobs on Walrus decentralized storage
4
+
5
+ ## Installation
6
+
7
+ ```bash npm2yarn
8
+ npm install --save @mysten/walrus @mysten/sui
9
+ ```
10
+
11
+ ## Setup
12
+
13
+ To use the walrus SDK you will need to create a Client from the typescript SDK, and extend it with
14
+ the walrus SDK.
15
+
16
+ ```ts
17
+ const client = new SuiGrpcClient({
18
+ network: 'testnet',
19
+ baseUrl: 'https://fullnode.testnet.sui.io:443',
20
+ }).$extend(walrus());
21
+ ```
22
+
23
+ The walrus SDK currently includes all the relevant package and object IDs needed for connecting to
24
+ testnet. You can also manually configure the walrus sdk to use a different set of ids, allowing you
25
+ to connect to a different network or updated deployment of the walrus contracts.
26
+
27
+ ```ts
28
+ const client = new SuiGrpcClient({
29
+ network: 'testnet',
30
+ baseUrl: 'https://fullnode.testnet.sui.io:443',
31
+ }).$extend(
32
+ walrus({
33
+ packageConfig: {
34
+ systemObjectId: '0x98ebc47370603fe81d9e15491b2f1443d619d1dab720d586e429ed233e1255c1',
35
+ stakingPoolId: '0x20266a17b4f1a216727f3eef5772f8d486a9e3b5e319af80a5b75809c035561d',
36
+ },
37
+ }),
38
+ );
39
+ ```
40
+
41
+ For some environments you may need to customize how data is fetched:
42
+
43
+ ```ts
44
+ const client = new SuiGrpcClient({
45
+ network: 'testnet',
46
+ baseUrl: 'https://fullnode.testnet.sui.io:443',
47
+ }).$extend(
48
+ walrus({
49
+ storageNodeClientOptions: {
50
+ fetch: (url, options) => {
51
+ console.log('fetching', url);
52
+ return fetch(url, options);
53
+ },
54
+ timeout: 60_000,
55
+ },
56
+ }),
57
+ );
58
+ ```
59
+
60
+ This can be used to implement a fetch function with custom timeouts, rate limits, retry logic, or
61
+ any other desired behavior.
62
+
63
+ ## SDK Overview
64
+
65
+ The Walrus TS SDK is designed to work directly with walrus storage nodes, or with the walrus upload
66
+ relay. When using the walrus SDK without an upload relay, it is important to understand that reading
67
+ and writing walrus blobs requires a lot of requests (~2200 to write a blob, ~335 to read a blob).
68
+ The upload relay will reduce the number of requests needed to write a blob, but reads through the
69
+ walrus SDK will still require a lot of requests. For many applications, using publishers and
70
+ aggregators is recommended, but the TS SDK can be useful when building applications where the
71
+ application needs to directly interact with walrus or users need to pay for their own storage
72
+ directly.
73
+
74
+ The walrus sdk exposes high level methods for reading and writing blobs, as well as lower level
75
+ methods for the individual steps in the process that can be used to implement more complex flows
76
+ when you want more control to implement more optimized implementations.
77
+
78
+ ## WalrusFiles
79
+
80
+ The `WalrusFile` API provides a higher level abstraction so that applications don't need to worry
81
+ about how data is stored in walrus. Today it handles data stored directly in blobs, and data stored
82
+ in Quilts, but may be expanded to cover other storage patterns in the future.
83
+
84
+ ### Reading files
85
+
86
+ To read files, you can use the `getFiles` method. This method accepts both Blob IDs and Quilt IDs,
87
+ and will return a `WalrusFile`.
88
+
89
+ It is encouraged to always read files in batches when possible, which will allow the client to be
90
+ more efficient when loading multiple files from the same quilt.
91
+
92
+ ```ts
93
+ const [file1, file2] = await client.walrus.getFiles({ ids: [anyBlobId, orQuiltId] });
94
+ ```
95
+
96
+ A `WalrusFile` works like a `Response` object from the `fetch` API:
97
+
98
+ ```ts
99
+ // get contents as a Uint8Array
100
+ const bytes = await file1.bytes();
101
+ // Parse the contents as a `utf-8` string
102
+ const text = await file1.text();
103
+ // Parse the contents as JSON
104
+ const json = await file2.json();
105
+ ```
106
+
107
+ A `WalrusFile` may also have and `identifier` and `tags` properties if the file was stored in a
108
+ quilt.
109
+
110
+ ```ts
111
+ const identifier: string | null = await file1.getIdentifier();
112
+ const tags: Record<string, string> = await file1.getTags();
113
+ ```
114
+
115
+ ### WalrusBlobs
116
+
117
+ You can also get a `WalrusBlob` instead of a `WalrusFile` if you have the blobId:
118
+
119
+ ```ts
120
+ const blob = await client.walrus.getBlob({ blobId });
121
+ ```
122
+
123
+ If the blob is a quilt, you can read the files in the quilt:
124
+
125
+ ```ts
126
+ // Get all files:
127
+ const files = await blob.files();
128
+ // Get files by identifier
129
+ const [readme] = await blob.files({ identifiers: ['README.md'] });
130
+ // Get files by tag
131
+ const textFiles = await blob.files({ tags: [{ 'content-type': 'text/plain' }] });
132
+ // Get files by quilt id
133
+ const filesById = await blob.files({ ids: [quiltID] });
134
+ ```
135
+
136
+ ### Writing files
137
+
138
+ You can also construct a `WalrusFile` from a `Uint8Array`, `Blob`, or a `string` which can then be
139
+ stored on walrus:
140
+
141
+ ```ts
142
+ const file1 = WalrusFile.from({
143
+ contents: new Uint8Array([1, 2, 3]),
144
+ identifier: 'file1.bin',
145
+ });
146
+ const file2 = WalrusFile.from({
147
+ contents: new Blob([new Uint8Array([1, 2, 3])]),
148
+ identifier: 'file2.bin',
149
+ });
150
+ const file3 = WalrusFile.from({
151
+ contents: new TextEncoder().encode('Hello from the TS SDK!!!\n'),
152
+ identifier: 'README.md',
153
+ tags: {
154
+ 'content-type': 'text/plain',
155
+ },
156
+ });
157
+ ```
158
+
159
+ Once you have your files you can use the `writeFiles` method to write them to walrus.
160
+
161
+ Along with the files, you will also need to provide a `Signer` instance that signs and pays for the
162
+ transaction/storage fees. The signer's address will need to have sufficient `SUI` to cover the
163
+ transactions that register the blob, and certify its availability after it's been uploaded. The
164
+ Signer must own sufficient `WAL` to pay to store the blob for the specified number of epochs, as
165
+ well as the write fee for writing the blob.
166
+
167
+ The exact costs will depend on the size of the blobs, as well as the current gas and storage prices.
168
+
169
+ ```ts
170
+ const results: {
171
+ id: string;
172
+ blobId: string;
173
+ blobObject: Blob.$inferType;
174
+ }[] = await client.walrus.writeFiles({
175
+ files: [file1, file2, file3],
176
+ epochs: 3,
177
+ deletable: true,
178
+ signer: keypair,
179
+ });
180
+ ```
181
+
182
+ Currently, the provided files will all be written into a single quilt. Future versions of the SDK
183
+ may optimize how files are stored to be more efficient by splitting files into multiple quilts.
184
+
185
+ The current quilt encoding is less efficient for single files, so writing multiple files together is
186
+ recommended when possible. Writing raw blobs directly is also possible using the `writeBlob` API
187
+ (described below)
188
+
189
+ ### Writing files in browser environments
190
+
191
+ When the transactions to upload a blob are signed by a wallet in a browser, some wallets will use
192
+ popups to prompt the user for a signature. If the popups are not opened in direct response to a user
193
+ interaction, they may be blocked by the browser.
194
+
195
+ To avoid this, we need to ensure that we execute the transactions that register and certify the blob
196
+ in separate events handlers by creating separate buttons for the user to click for each step.
197
+
198
+ The `client.writeFilesFlow` method returns an object with a set of methods that break the write flow
199
+ into several smaller steps:
200
+
201
+ 1. `encode` - Encodes the files and generates a blobId
202
+ 2. `register` - returns a transaction that will register the blob on-chain
203
+ 3. `upload` - Uploads the data to storage nodes
204
+ 4. `certify` - returns a transaction that will certify the blob on-chain
205
+ 5. `listFiles` - returns a list of the created files
206
+
207
+ Here's a simplified example showing the core API usage with separate user interactions:
208
+
209
+ ```tsx
210
+ // Step 1: Create and encode the flow (can be done immediately when file is selected)
211
+ const flow = client.walrus.writeFilesFlow({
212
+ files: [
213
+ WalrusFile.from({
214
+ contents: new Uint8Array(fileData),
215
+ identifier: 'my-file.txt',
216
+ }),
217
+ ],
218
+ });
219
+
220
+ await flow.encode();
221
+
222
+ // Step 2: Register the blob (triggered by user clicking a register button after the encode step)
223
+ async function handleRegister() {
224
+ const registerTx = flow.register({
225
+ epochs: 3,
226
+ owner: currentAccount.address,
227
+ deletable: true,
228
+ });
229
+ const result = await signAndExecuteTransaction({ transaction: registerTx });
230
+
231
+ // Check transaction status
232
+ if (result.$kind === 'FailedTransaction') {
233
+ throw new Error(`Registration failed: ${result.FailedTransaction.status.error?.message}`);
234
+ }
235
+
236
+ // Step 3: Upload the data to storage nodes
237
+ // This can be done immediately after the register step, or as a separate step the user initiates
238
+ await flow.upload({ digest: result.Transaction.digest });
239
+ }
240
+
241
+ // Step 4: Certify the blob (triggered by user clicking a certify button after the blob is uploaded)
242
+ async function handleCertify() {
243
+ const certifyTx = flow.certify();
244
+
245
+ const result = await signAndExecuteTransaction({ transaction: certifyTx });
246
+
247
+ // Check transaction status
248
+ if (result.$kind === 'FailedTransaction') {
249
+ throw new Error(`Certification failed: ${result.FailedTransaction.status.error?.message}`);
250
+ }
251
+
252
+ // Step 5: Get the new files
253
+ const files = await flow.listFiles();
254
+ console.log('Uploaded files', files);
255
+ }
256
+ ```
257
+
258
+ This approach ensures that each transaction signing step is separated into different user
259
+ interactions, allowing wallet popups to work properly without being blocked by the browser.
260
+
261
+ ## Writing blobs with an upload relay
262
+
263
+ Writing blobs directly from a client requires a lot of requests to write data to all the storage
264
+ nodes. An upload relay can be used to offload the work of these writes to a server, reducing
265
+ complexity for the client.
266
+
267
+ To use an upload relay, you can add the `uploadRelay` option when adding the walrus extension:
268
+
269
+ ```ts
270
+ const client = new SuiGrpcClient({
271
+ network: 'testnet',
272
+ baseUrl: 'https://fullnode.testnet.sui.io:443',
273
+ }).$extend(
274
+ walrus({
275
+ uploadRelay: {
276
+ host: 'https://upload-relay.testnet.walrus.space',
277
+ sendTip: {
278
+ max: 1_000,
279
+ },
280
+ },
281
+ }),
282
+ );
283
+ ```
284
+
285
+ The `host` option is required, and indicates the url for your upload relay. Upload relays may
286
+ require a tip to be included to cover the cost of writing the blob. You can configure a maximum tip
287
+ (paid in MIST) and the `WalrusClient` will automatically determine the required tip for your upload
288
+ relay, or you can manually configure the tip configuration as shown below.
289
+
290
+ The tip required by an upload relay can be found using the `tip-config` endpoint: (e.g.
291
+ `https://upload-relay.testnet.walrus.space/v1/tip-config`) and may either be a `const` or a `linear`
292
+ tip.
293
+
294
+ ### `const` tip
295
+
296
+ A `const` will send a fixed amount for each blob written to the upload relay.
297
+
298
+ ```ts
299
+ const client = new SuiGrpcClient({
300
+ network: 'testnet',
301
+ baseUrl: 'https://fullnode.testnet.sui.io:443',
302
+ }).$extend(
303
+ walrus({
304
+ uploadRelay: {
305
+ host: 'https://upload-relay.testnet.walrus.space',
306
+ sendTip: {
307
+ address: '0x123...',
308
+ kind: {
309
+ const: 105,
310
+ },
311
+ },
312
+ },
313
+ }),
314
+ );
315
+ ```
316
+
317
+ ### `linear` tip
318
+
319
+ A `linear` tip will send a fixed amount for each blob written to the fan out proxy, plus a
320
+ multiplier based on the size of the blob.
321
+
322
+ ```ts
323
+ const client = new SuiGrpcClient({
324
+ network: 'testnet',
325
+ baseUrl: 'https://fullnode.testnet.sui.io:443',
326
+ }).$extend(
327
+ walrus({
328
+ uploadRelay: {
329
+ host: 'https://upload-relay.testnet.walrus.space',
330
+ sendTip: {
331
+ address: '0x123...',
332
+ kind: {
333
+ linear: {
334
+ base: 105,
335
+ perEncodedKib: 10,
336
+ },
337
+ },
338
+ },
339
+ },
340
+ }),
341
+ );
342
+ ```
343
+
344
+ ## Interacting with blobs directly
345
+
346
+ In case you do not want to use the `WalrusFile` abstractions, you can use the `readBlob` and
347
+ `writeBlob` APIs directly
348
+
349
+ ### Reading blobs
350
+
351
+ The `readBlob` method will read a blob given the blobId and return Uint8Array containing the blobs
352
+ content:
353
+
354
+ ```ts
355
+ const blob = await client.walrus.readBlob({ blobId });
356
+ ```
357
+
358
+ ### Writing Blobs
359
+
360
+ The writeBlob method can be used to write a blob (as a `Uint8Array`) to walrus. You will need to
361
+ specify how long the blob should be stored for, and if the blob should be deletable.
362
+
363
+ ```ts
364
+ const file = new TextEncoder().encode('Hello from the TS SDK!!!\n');
365
+
366
+ const { blobId } = await client.walrus.writeBlob({
367
+ blob: file,
368
+ deletable: false,
369
+ epochs: 3,
370
+ signer: keypair,
371
+ });
372
+ ```
373
+
374
+ ## Full API
375
+
376
+ For a complete overview of the available methods on the `WalrusClient` you can reference type
377
+ [TypeDocs](/typedoc/classes/_mysten_walrus.WalrusClient.html)
378
+
379
+ ## Examples
380
+
381
+ There are a number of simple
382
+ [examples you can reference](https://github.com/MystenLabs/ts-sdks/tree/main/packages/walrus/examples)
383
+ in the `ts-sdks` repo that show things like building simple aggregators and publishers with the
384
+ walrus SDK
385
+
386
+ ## Error handling
387
+
388
+ The SDK exports all the error classes for different types of errors that can be thrown. Walrus is a
389
+ fault-tolerant distributed system, where many types of errors can be recovered from. During epoch
390
+ changes there may be times when the data cached in the `WalrusClient` can become invalid. Errors
391
+ that result from this situation will extend the `RetryableWalrusClientError` class.
392
+
393
+ You can check for these errors, and reset the client before retrying:
394
+
395
+ ```ts
396
+ if (error instanceof RetryableWalrusClientError) {
397
+ client.walrus.reset();
398
+
399
+ /* retry your operation */
400
+ }
401
+ ```
402
+
403
+ `RetryableWalrusClientError` are not guaranteed to succeed after resetting the client and retrying,
404
+ but this pattern can be used to handle some edge cases.
405
+
406
+ High level methods like `readBlob` already handle various error cases and will automatically retry
407
+ when hitting these methods, as well as handling cases where only a subset of nodes need to respond
408
+ successfully to read or publish a blob.
409
+
410
+ When using the lower level methods to build your own read or publish flows, it is recommended to
411
+ understand the number of shards/sliver that need to be successfully written or read for you
412
+ operation to succeed, and gracefully handle cases where some nodes may be in a bad state.
413
+
414
+ ### Network errors
415
+
416
+ Walrus is designed to handle some nodes being down, and the SDK will only throw errors when it can't
417
+ read from or write to enough storage nodes. When trying to troubleshoot problems, it can be
418
+ challenging to figure out what's going wrong when you don't see all the individual network errors.
419
+
420
+ You can pass an `onError` option in the storageNodeClientOptions to get the individual errors from
421
+ failed requests:
422
+
423
+ ```ts
424
+ const client = new SuiGrpcClient({
425
+ network: 'testnet',
426
+ baseUrl: 'https://fullnode.testnet.sui.io:443',
427
+ }).$extend(
428
+ walrus({
429
+ storageNodeClientOptions: {
430
+ onError: (error) => console.log(error),
431
+ },
432
+ }),
433
+ );
434
+ ```
435
+
436
+ ## Configuring network requests
437
+
438
+ Reading and writing blobs directly from storage nodes requires a lot of requests. The walrus SDK
439
+ will issue all requests needed to complete these operations, but does not handling all the
440
+ complexities a robust aggregator or publisher might encounter.
441
+
442
+ By default, all requests are issued using the global `fetch` for whatever runtime the SDK is running
443
+ in.
444
+
445
+ This will not impose any limitations on concurrency, and will be subject to default timeouts and
446
+ behavior defined by your runtime. To customize how requests are made, you can provide a custom
447
+ `fetch` method:
448
+
449
+ ```ts
450
+ const client = new SuiGrpcClient({
451
+ network: 'testnet',
452
+ baseUrl: 'https://fullnode.testnet.sui.io:443',
453
+ }).$extend(
454
+ walrus({
455
+ storageNodeClientOptions: {
456
+ timeout: 60_000,
457
+ fetch: (url, init) => {
458
+ // Some casting may be required because undici types may not exactly match the @node/types types
459
+ return fetch(url as RequestInfo, {
460
+ ...(init as RequestInit),
461
+ dispatcher: new Agent({
462
+ connectTimeout: 60_000,
463
+ }),
464
+ }) as unknown as Promise<Response>;
465
+ },
466
+ },
467
+ }),
468
+ );
469
+ ```
470
+
471
+ ## Loading the wasm module in vite or client side apps
472
+
473
+ The walrus SDK requires wasm bindings to encode and decode blobs. When running in node or bun and
474
+ some bundlers this will work without any additional configuration.
475
+
476
+ In some cases you may need to manually specify where the SDK loads the wasm bindings from.
477
+
478
+ In vite you can get the url for the wasm bindings by importing the wasm file with a `?url` suffix,
479
+ and then passed into the walrus client:
480
+
481
+ ```ts
482
+ const client = new SuiGrpcClient({
483
+ network: 'testnet',
484
+ baseUrl: 'https://fullnode.testnet.sui.io:443',
485
+ }).$extend(
486
+ walrus({
487
+ wasmUrl: walrusWasmUrl,
488
+ }),
489
+ );
490
+ ```
491
+
492
+ If you are unable to get a url for the wasm file in your bundler or build system, you can self host
493
+ the wasm bindings, or load them from a CDN:
494
+
495
+ ```ts
496
+ const client = new SuiGrpcClient({
497
+ network: 'testnet',
498
+ baseUrl: 'https://fullnode.testnet.sui.io:443',
499
+ }).$extend(
500
+ walrus({
501
+ wasmUrl: 'https://unpkg.com/@mysten/walrus-wasm@latest/web/walrus_wasm_bg.wasm',
502
+ }),
503
+ );
504
+ ```
505
+
506
+ In next.js when using walrus in API routes, you may need to tell next.js to skip bundling for the
507
+ walrus packages:
508
+
509
+ ```ts
510
+ // next.config.ts
511
+ const nextConfig: NextConfig = {
512
+ serverExternalPackages: ['@mysten/walrus', '@mysten/walrus-wasm'],
513
+ };
514
+ ```
515
+
516
+ ## Known fetch limitations you might run into
517
+
518
+ - Some nodes can be slow to respond. When running in node, the default connectTimeout is 10 seconds
519
+ and can cause request timeouts
520
+ - In `bun` the `abort` signal will stop requests from responding, but they still wait for completion
521
+ before their promises reject
@@ -0,0 +1,5 @@
1
+ # Walrus
2
+
3
+ > Publish and Read blobs directly from walrus storage nodes
4
+
5
+ - [Walrus SDK](./index.md): Store and retrieve blobs on Walrus decentralized storage
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mysten/walrus",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "private": false,
5
5
  "description": "Walrus SDK",
6
6
  "license": "Apache-2.0",
@@ -18,7 +18,8 @@
18
18
  "sideEffects": false,
19
19
  "files": [
20
20
  "CHANGELOG.md",
21
- "dist"
21
+ "dist",
22
+ "docs"
22
23
  ],
23
24
  "repository": {
24
25
  "type": "git",
@@ -35,30 +36,31 @@
35
36
  "@types/react": "^19.2.8",
36
37
  "@types/react-dom": "^19.2.3",
37
38
  "@vitejs/plugin-react": "^5.1.2",
38
- "hono": "^4.11.7",
39
+ "hono": "^4.12.2",
39
40
  "react": "^19.2.3",
40
41
  "react-dom": "^19.2.3",
41
42
  "typescript": "^5.9.3",
42
43
  "undici": "^7.18.2",
43
44
  "vite": "^7.3.1",
44
45
  "vitest": "^4.0.17",
45
- "@mysten/codegen": "^0.8.1",
46
- "@mysten/dapp-kit-core": "^1.0.4",
47
- "@mysten/dapp-kit-react": "^1.0.2",
48
- "@mysten/sui": "^2.3.2"
46
+ "@mysten/codegen": "^0.8.3",
47
+ "@mysten/dapp-kit-core": "^1.2.0",
48
+ "@mysten/dapp-kit-react": "^2.0.1",
49
+ "@mysten/sui": "^2.8.0"
49
50
  },
50
51
  "dependencies": {
51
52
  "dataloader": "^2.2.3",
52
- "@mysten/bcs": "^2.0.2",
53
- "@mysten/walrus-wasm": "^0.2.0",
54
- "@mysten/utils": "^0.3.1"
53
+ "@mysten/bcs": "^2.0.3",
54
+ "@mysten/utils": "^0.3.1",
55
+ "@mysten/walrus-wasm": "^0.2.0"
55
56
  },
56
57
  "peerDependencies": {
57
- "@mysten/sui": "^2.3.2"
58
+ "@mysten/sui": "^2.8.0"
58
59
  },
59
60
  "scripts": {
60
61
  "clean": "rm -rf tsconfig.tsbuildinfo ./dist",
61
62
  "build": "rm -rf dist && tsc --noEmit && tsdown",
63
+ "build:docs": "tsx ../docs/scripts/build-docs.ts",
62
64
  "test": "pnpm test:examples && NODE_OPTIONS='--expose-gc' vitest run",
63
65
  "test:examples": "tsc --project examples/tsconfig.json --noEmit",
64
66
  "codegen": "sui-ts-codegen generate && pnpm lint:fix",