@mysten/walrus 0.8.5 → 0.9.0
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 +20 -0
- package/dist/cjs/client.d.ts +7 -39
- package/dist/cjs/client.js +27 -22
- package/dist/cjs/client.js.map +3 -3
- package/dist/cjs/contracts/utils/index.js +1 -1
- package/dist/cjs/contracts/utils/index.js.map +2 -2
- package/dist/cjs/files/readers/blob.js +2 -1
- package/dist/cjs/files/readers/blob.js.map +2 -2
- package/dist/cjs/storage-node/client.js +1 -1
- package/dist/cjs/storage-node/client.js.map +2 -2
- package/dist/cjs/storage-node/types.d.ts +1 -1
- package/dist/cjs/storage-node/types.js.map +1 -1
- package/dist/cjs/utils/quilts.js +1 -1
- package/dist/cjs/utils/quilts.js.map +2 -2
- package/dist/cjs/wasm.d.ts +7 -4
- package/dist/cjs/wasm.js +49 -15
- package/dist/cjs/wasm.js.map +2 -2
- package/dist/esm/client.d.ts +7 -39
- package/dist/esm/client.js +28 -23
- package/dist/esm/client.js.map +3 -3
- package/dist/esm/contracts/utils/index.js +1 -1
- package/dist/esm/contracts/utils/index.js.map +2 -2
- package/dist/esm/files/readers/blob.js +2 -1
- package/dist/esm/files/readers/blob.js.map +2 -2
- package/dist/esm/storage-node/client.js +1 -1
- package/dist/esm/storage-node/client.js.map +2 -2
- package/dist/esm/storage-node/types.d.ts +1 -1
- package/dist/esm/utils/quilts.js +1 -1
- package/dist/esm/utils/quilts.js.map +2 -2
- package/dist/esm/wasm.d.ts +7 -4
- package/dist/esm/wasm.js +49 -15
- package/dist/esm/wasm.js.map +2 -2
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -20
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/contracts/utils/index.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { BcsType, TypeTag } from '@mysten/sui/bcs';\nimport { bcs, TypeTagSerializer, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\nimport type { TransactionArgument } from '@mysten/sui/transactions';\nimport { isArgument } from '@mysten/sui/transactions';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\nconst SUI_SYSTEM_ADDRESS = normalizeSuiAddress('0x3');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\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(parsedTag.struct.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 (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === 'Object' && structTag.name === 'ID') {\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: string[],\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 === `${SUI_FRAMEWORK_ADDRESS}::deny_list::DenyList`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::random::Random`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::clock::Clock`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_SYSTEM_ADDRESS}::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
|
|
5
|
-
"mappings": "AAGA,SAAS,KAAK,mBAAmB,WAAW,SAAS,gBAAgB;AACrE,SAAS,2BAA2B;AAEpC,SAAS,kBAAkB;AAE3B,MAAM,sBAAsB,oBAAoB,KAAK;AACrD,MAAM,wBAAwB,oBAAoB,KAAK;AACvD,MAAM,qBAAqB,oBAAoB,KAAK;AAI7C,SAAS,iBAAiB,SAAgD;AAChF,QAAM,YAAY,OAAO,YAAY,WAAW,kBAAkB,aAAa,OAAO,IAAI;AAE1F,MAAI,QAAQ,WAAW;AACtB,WAAO,IAAI;AAAA,EACZ,WAAW,SAAS,WAAW;AAC9B,WAAO,IAAI;AAAA,EACZ,WAAW,SAAS,WAAW;AAC9B,WAAO,IAAI;AAAA,EACZ,WAAW,SAAS,WAAW;AAC9B,WAAO,IAAI;AAAA,EACZ,WAAW,UAAU,WAAW;AAC/B,WAAO,IAAI;AAAA,EACZ,WAAW,UAAU,WAAW;AAC/B,WAAO,IAAI;AAAA,EACZ,WAAW,aAAa,WAAW;AAClC,WAAO,IAAI;AAAA,EACZ,WAAW,UAAU,WAAW;AAC/B,WAAO,IAAI;AAAA,EACZ,WAAW,YAAY,WAAW;AACjC,UAAM,OAAO,iBAAiB,UAAU,MAAM;AAC9C,WAAO,OAAO,IAAI,OAAO,IAAI,IAAI;AAAA,EAClC,WAAW,YAAY,WAAW;AACjC,UAAM,YAAY,UAAU;AAC5B,UAAM,MAAM,oBAAoB,UAAU,OAAO,OAAO;AAExD,QAAI,QAAQ,qBAAqB;AAChC,WACE,UAAU,WAAW,WAAW,UAAU,WAAW,aACtD,UAAU,SAAS,UAClB;AACD,eAAO,IAAI;AAAA,MACZ;AAEA,UAAI,UAAU,WAAW,YAAY,UAAU,SAAS,UAAU;AACjE,cAAM,OAAO,iBAAiB,UAAU,WAAW,CAAC,CAAE;AACtD,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AI,MAAM,6CAA6C;AAAA,MAC9D;AACA,YAAM,OAAO,eAAe,KAAK;AACjC,YAAM,KAAK,IAAyB;AAEpC,UAAI,
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport type { BcsType, TypeTag } from '@mysten/sui/bcs';\nimport { bcs, TypeTagSerializer, BcsStruct, BcsEnum, BcsTuple } from '@mysten/sui/bcs';\nimport { normalizeSuiAddress } from '@mysten/sui/utils';\nimport type { TransactionArgument } from '@mysten/sui/transactions';\nimport { isArgument } from '@mysten/sui/transactions';\n\nconst MOVE_STDLIB_ADDRESS = normalizeSuiAddress('0x1');\nconst SUI_FRAMEWORK_ADDRESS = normalizeSuiAddress('0x2');\nconst SUI_SYSTEM_ADDRESS = normalizeSuiAddress('0x3');\n\nexport type RawTransactionArgument<T> = T | TransactionArgument;\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(parsedTag.struct.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 (pkg === SUI_FRAMEWORK_ADDRESS && structTag.module === 'Object' && structTag.name === 'ID') {\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: string[],\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 === `${SUI_FRAMEWORK_ADDRESS}::deny_list::DenyList`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.denyList());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::random::Random`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.random());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_FRAMEWORK_ADDRESS}::clock::Clock`) {\n\t\t\tnormalizedArgs.push((tx) => tx.object.clock());\n\t\t\tcontinue;\n\t\t}\n\n\t\tif (argType === `${SUI_SYSTEM_ADDRESS}::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 = 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\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: unknown) => val);\n\t}\n\tif (typeof val === 'bigint') {\n\t\treturn val.toString();\n\t}\n\n\treturn val;\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,KAAK,mBAAmB,WAAW,SAAS,gBAAgB;AACrE,SAAS,2BAA2B;AAEpC,SAAS,kBAAkB;AAE3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cAAc,WAAW,GAAG,GAAG;AACjD,qBAAe,KAAK,GAA0B;AAC9C;AAAA,IACD;AAEA,UAAM,OAAO,SAAS,CAAC;AACvB,UAAM,UAAU,iBAAiB,IAAI;AAErC,QAAI,SAAS;AACZ,YAAM,QAAQ,QAAQ,UAAU,GAAY;AAC5C,qBAAe,KAAK,CAAC,OAAO,GAAG,KAAK,KAAK,CAAC;AAC1C;AAAA,IACD,WAAW,OAAO,QAAQ,UAAU;AACnC,qBAAe,KAAK,CAAC,OAAO,GAAG,OAAO,GAAG,CAAC;AAC1C;AAAA,IACD;AAEA,UAAM,IAAI,MAAM,oBAAoB,UAAU,GAAG,CAAC,aAAa,IAAI,EAAE;AAAA,EACtE;AAEA,SAAO;AACR;AAEO,MAAM,mBAGH,UAAmB;AAAC;AAEvB,MAAM,iBAGH,QAAiB;AAAC;AAErB,MAAM,kBAGH,SAAkB;AAAC;AAE7B,SAAS,UAAU,KAAc;AAChC,MAAI,OAAO,QAAQ,UAAU;AAC5B,WAAO,KAAK,UAAU,KAAK,CAACA,SAAiBA,IAAG;AAAA,EACjD;AACA,MAAI,OAAO,QAAQ,UAAU;AAC5B,WAAO,IAAI,SAAS;AAAA,EACrB;AAEA,SAAO;AACR;",
|
|
6
6
|
"names": ["val"]
|
|
7
7
|
}
|
|
@@ -9,6 +9,7 @@ var _cache, _client, _secondarySlivers, _numShards;
|
|
|
9
9
|
import { ClientCache } from "@mysten/sui/experimental";
|
|
10
10
|
import { getSizes, getSourceSymbols } from "../../utils/index.js";
|
|
11
11
|
import { QuiltReader } from "./quilt.js";
|
|
12
|
+
import { SliverData } from "../../utils/bcs.js";
|
|
12
13
|
class BlobReader {
|
|
13
14
|
constructor({ client, blobId, numShards }) {
|
|
14
15
|
__privateAdd(this, _cache, new ClientCache());
|
|
@@ -90,7 +91,7 @@ class BlobReader {
|
|
|
90
91
|
blobId: this.blobId,
|
|
91
92
|
index: sliverIndex,
|
|
92
93
|
signal
|
|
93
|
-
}).then((sliver) =>
|
|
94
|
+
}).then((sliver) => SliverData.parse(sliver).symbols.data);
|
|
94
95
|
__privateGet(this, _secondarySlivers).set(sliverIndex, sliverPromise);
|
|
95
96
|
try {
|
|
96
97
|
const sliver = await sliverPromise;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/files/readers/blob.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { ClientCache } from '@mysten/sui/experimental';\nimport type { FileReader } from '../file.js';\nimport type { WalrusClient } from '../../client.js';\nimport { getSizes, getSourceSymbols } from '../../utils/index.js';\nimport { QuiltReader } from './quilt.js';\n\nexport interface BlobReaderOptions {\n\tclient: WalrusClient;\n\tblobId: string;\n\tnumShards: number;\n}\n\nexport class BlobReader implements FileReader {\n\tblobId: string;\n\n\t#cache = new ClientCache();\n\n\t#client: WalrusClient;\n\t#secondarySlivers = new Map<number, Uint8Array | Promise<Uint8Array>>();\n\thasStartedLoadingFullBlob = false;\n\t#numShards: number;\n\n\tconstructor({ client, blobId, numShards }: BlobReaderOptions) {\n\t\tthis.#client = client;\n\t\tthis.blobId = blobId;\n\t\tthis.#numShards = numShards;\n\t}\n\n\tasync getIdentifier() {\n\t\treturn null;\n\t}\n\n\tasync getTags() {\n\t\treturn {};\n\t}\n\n\tgetQuiltReader() {\n\t\treturn new QuiltReader({ blob: this });\n\t}\n\n\tasync getBytes() {\n\t\treturn this.#cache.read(['getBytes'], async () => {\n\t\t\tthis.hasStartedLoadingFullBlob = true;\n\t\t\ttry {\n\t\t\t\tconst blob = await this.#client.readBlob({ blobId: this.blobId });\n\t\t\t\treturn blob;\n\t\t\t} catch (error) {\n\t\t\t\tthis.hasStartedLoadingFullBlob = false;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t});\n\t}\n\n\tgetMetadata() {\n\t\treturn this.#cache.read(['getMetadata'], () =>\n\t\t\tthis.#client.getBlobMetadata({ blobId: this.blobId }),\n\t\t);\n\t}\n\n\tasync getColumnSize() {\n\t\treturn this.#cache.read(['getColumnSize'], async () => {\n\t\t\tconst loadingSlivers = [...this.#secondarySlivers.values()];\n\n\t\t\tif (loadingSlivers.length > 0) {\n\t\t\t\tconst sliver = await Promise.any(loadingSlivers).catch(() => null);\n\n\t\t\t\tif (sliver) {\n\t\t\t\t\treturn sliver.length;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.hasStartedLoadingFullBlob) {\n\t\t\t\tconst blob = await this.getBytes();\n\t\t\t\tconst { columnSize } = getSizes(blob.length, this.#numShards);\n\t\t\t\treturn columnSize;\n\t\t\t}\n\n\t\t\tconst metadata = await this.getMetadata();\n\t\t\tconst { columnSize } = getSizes(\n\t\t\t\tNumber(metadata.metadata.V1.unencoded_length),\n\t\t\t\tthis.#numShards,\n\t\t\t);\n\n\t\t\treturn columnSize;\n\t\t});\n\t}\n\n\tasync getSymbolSize() {\n\t\tconst columnSize = await this.getColumnSize();\n\t\tconst { primarySymbols } = getSourceSymbols(this.#numShards);\n\n\t\tif (columnSize % primarySymbols !== 0) {\n\t\t\tthrow new Error('column size should be divisible by primary symbols');\n\t\t}\n\n\t\treturn columnSize / primarySymbols;\n\t}\n\n\tasync getRowSize() {\n\t\tconst symbolSize = await this.getSymbolSize();\n\t\tconst { secondarySymbols } = getSourceSymbols(this.#numShards);\n\t\treturn symbolSize * secondarySymbols;\n\t}\n\n\tasync getSecondarySliver({ sliverIndex, signal }: { sliverIndex: number; signal?: AbortSignal }) {\n\t\tif (this.#secondarySlivers.has(sliverIndex)) {\n\t\t\treturn this.#secondarySlivers.get(sliverIndex)!;\n\t\t}\n\n\t\tconst sliverPromise = this.#client\n\t\t\t.getSecondarySliver({\n\t\t\t\tblobId: this.blobId,\n\t\t\t\tindex: sliverIndex,\n\t\t\t\tsignal,\n\t\t\t})\n\t\t\t.then((sliver) =>
|
|
5
|
-
"mappings": ";;;;;;;AAAA;AAEA,SAAS,mBAAmB;AAG5B,SAAS,UAAU,wBAAwB;AAC3C,SAAS,mBAAmB;
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\nimport { ClientCache } from '@mysten/sui/experimental';\nimport type { FileReader } from '../file.js';\nimport type { WalrusClient } from '../../client.js';\nimport { getSizes, getSourceSymbols } from '../../utils/index.js';\nimport { QuiltReader } from './quilt.js';\nimport { SliverData } from '../../utils/bcs.js';\n\nexport interface BlobReaderOptions {\n\tclient: WalrusClient;\n\tblobId: string;\n\tnumShards: number;\n}\n\nexport class BlobReader implements FileReader {\n\tblobId: string;\n\n\t#cache = new ClientCache();\n\n\t#client: WalrusClient;\n\t#secondarySlivers = new Map<number, Uint8Array | Promise<Uint8Array>>();\n\thasStartedLoadingFullBlob = false;\n\t#numShards: number;\n\n\tconstructor({ client, blobId, numShards }: BlobReaderOptions) {\n\t\tthis.#client = client;\n\t\tthis.blobId = blobId;\n\t\tthis.#numShards = numShards;\n\t}\n\n\tasync getIdentifier() {\n\t\treturn null;\n\t}\n\n\tasync getTags() {\n\t\treturn {};\n\t}\n\n\tgetQuiltReader() {\n\t\treturn new QuiltReader({ blob: this });\n\t}\n\n\tasync getBytes() {\n\t\treturn this.#cache.read(['getBytes'], async () => {\n\t\t\tthis.hasStartedLoadingFullBlob = true;\n\t\t\ttry {\n\t\t\t\tconst blob = await this.#client.readBlob({ blobId: this.blobId });\n\t\t\t\treturn blob;\n\t\t\t} catch (error) {\n\t\t\t\tthis.hasStartedLoadingFullBlob = false;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t});\n\t}\n\n\tgetMetadata() {\n\t\treturn this.#cache.read(['getMetadata'], () =>\n\t\t\tthis.#client.getBlobMetadata({ blobId: this.blobId }),\n\t\t);\n\t}\n\n\tasync getColumnSize() {\n\t\treturn this.#cache.read(['getColumnSize'], async () => {\n\t\t\tconst loadingSlivers = [...this.#secondarySlivers.values()];\n\n\t\t\tif (loadingSlivers.length > 0) {\n\t\t\t\tconst sliver = await Promise.any(loadingSlivers).catch(() => null);\n\n\t\t\t\tif (sliver) {\n\t\t\t\t\treturn sliver.length;\n\t\t\t\t}\n\t\t\t}\n\n\t\t\tif (this.hasStartedLoadingFullBlob) {\n\t\t\t\tconst blob = await this.getBytes();\n\t\t\t\tconst { columnSize } = getSizes(blob.length, this.#numShards);\n\t\t\t\treturn columnSize;\n\t\t\t}\n\n\t\t\tconst metadata = await this.getMetadata();\n\t\t\tconst { columnSize } = getSizes(\n\t\t\t\tNumber(metadata.metadata.V1.unencoded_length),\n\t\t\t\tthis.#numShards,\n\t\t\t);\n\n\t\t\treturn columnSize;\n\t\t});\n\t}\n\n\tasync getSymbolSize() {\n\t\tconst columnSize = await this.getColumnSize();\n\t\tconst { primarySymbols } = getSourceSymbols(this.#numShards);\n\n\t\tif (columnSize % primarySymbols !== 0) {\n\t\t\tthrow new Error('column size should be divisible by primary symbols');\n\t\t}\n\n\t\treturn columnSize / primarySymbols;\n\t}\n\n\tasync getRowSize() {\n\t\tconst symbolSize = await this.getSymbolSize();\n\t\tconst { secondarySymbols } = getSourceSymbols(this.#numShards);\n\t\treturn symbolSize * secondarySymbols;\n\t}\n\n\tasync getSecondarySliver({ sliverIndex, signal }: { sliverIndex: number; signal?: AbortSignal }) {\n\t\tif (this.#secondarySlivers.has(sliverIndex)) {\n\t\t\treturn this.#secondarySlivers.get(sliverIndex)!;\n\t\t}\n\n\t\tconst sliverPromise = this.#client\n\t\t\t.getSecondarySliver({\n\t\t\t\tblobId: this.blobId,\n\t\t\t\tindex: sliverIndex,\n\t\t\t\tsignal,\n\t\t\t})\n\t\t\t.then((sliver) => SliverData.parse(sliver).symbols.data);\n\n\t\tthis.#secondarySlivers.set(sliverIndex, sliverPromise);\n\n\t\ttry {\n\t\t\tconst sliver = await sliverPromise;\n\t\t\tthis.#secondarySlivers.set(sliverIndex, sliver);\n\t\t\treturn sliver;\n\t\t} catch (error) {\n\t\t\tthis.#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K,mBAAkB,IAAI,aAAa,MAAM;AAC9C,aAAO;AAAA,IACR,SAAS,OAAO;AACf,yBAAK,mBAAkB,OAAO,WAAW;AACzC,YAAM;AAAA,IACP;AAAA,EACD;AACD;AAjHC;AAEA;AACA;AAEA;",
|
|
6
6
|
"names": ["columnSize"]
|
|
7
7
|
}
|
|
@@ -98,7 +98,7 @@ class StorageNodeClient {
|
|
|
98
98
|
headers: mergeHeaders({ Accept: "application/octet-stream" }, options.headers)
|
|
99
99
|
});
|
|
100
100
|
const bcsBytes = await response.arrayBuffer();
|
|
101
|
-
return
|
|
101
|
+
return new Uint8Array(bcsBytes);
|
|
102
102
|
}
|
|
103
103
|
/**
|
|
104
104
|
* Stores a primary or secondary blob sliver at the storage node.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/storage-node/client.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BlobMetadata, BlobMetadataWithId, SliverData } from '../utils/bcs.js';\nimport {\n\tConnectionTimeoutError,\n\tStorageNodeAPIError,\n\tStorageNodeError,\n\tUserAbortError,\n} from './error.js';\nimport type {\n\tGetBlobMetadataRequestInput,\n\tGetBlobMetadataResponse,\n\tGetBlobStatusRequestInput,\n\tGetBlobStatusResponse,\n\tGetDeletableBlobConfirmationRequestInput,\n\tGetDeletableBlobConfirmationResponse,\n\tGetPermanentBlobConfirmationRequestInput,\n\tGetPermanentBlobConfirmationResponse,\n\tGetSliverRequestInput,\n\tGetSliverResponse,\n\tRawGetBlobStatusResponse,\n\tStoreBlobMetadataRequestInput,\n\tStoreBlobMetadataResponse,\n\tStoreSliverRequestInput,\n\tStoreSliverResponse,\n} from './types.js';\nimport { mergeHeaders } from './utils.js';\n\nexport type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;\n\nexport type StorageNodeClientOptions = {\n\t/**\n\t * An optional custom fetch function.\n\t *\n\t * If not provided, defaults to the global `fetch` function (`globalThis.fetch`).\n\t *\n\t * @default globalThis.fetch\n\t */\n\tfetch?: Fetch;\n\n\t/**\n\t * An optional timeout for requests.\n\t * @default 30_000ms (30 seconds)\n\t */\n\ttimeout?: number;\n\n\t/**\n\t * Callback for individual network errors.\n\t */\n\tonError?: (error: Error) => void;\n};\n\nexport type RequestOptions = {\n\tnodeUrl: string;\n\ttimeout?: number;\n\theaders?: ReturnType<typeof mergeHeaders>;\n} & Omit<RequestInit, 'headers'>;\n\nexport class StorageNodeClient {\n\t#fetch: Fetch;\n\t#timeout: number;\n\t#onError?: (error: Error) => void;\n\tconstructor({ fetch: overriddenFetch, timeout, onError }: StorageNodeClientOptions = {}) {\n\t\tthis.#fetch = overriddenFetch ?? globalThis.fetch;\n\t\tthis.#timeout = timeout ?? 30_000;\n\t\tthis.#onError = onError;\n\t}\n\n\t/**\n\t * Gets the metadata associated with a Walrus blob.\n\t */\n\tasync getBlobMetadata(\n\t\t{ blobId }: GetBlobMetadataRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetBlobMetadataResponse> {\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/metadata`, {\n\t\t\t...options,\n\t\t\theaders: mergeHeaders({ Accept: 'application/octet-stream' }, options.headers),\n\t\t});\n\n\t\tconst bcsBytes = await response.arrayBuffer();\n\t\treturn BlobMetadataWithId.parse(new Uint8Array(bcsBytes));\n\t}\n\n\t/**\n\t * Gets the status associated with a Walrus blob.\n\t */\n\tasync getBlobStatus(\n\t\t{ blobId }: GetBlobStatusRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetBlobStatusResponse> {\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/status`, options);\n\n\t\tconst json: RawGetBlobStatusResponse = await response.json();\n\t\tconst blobStatus = json.success.data;\n\n\t\tif (blobStatus === 'nonexistent') {\n\t\t\treturn { type: 'nonexistent' };\n\t\t}\n\n\t\tif ('invalid' in blobStatus) {\n\t\t\treturn {\n\t\t\t\ttype: 'invalid',\n\t\t\t\t...blobStatus.invalid,\n\t\t\t};\n\t\t}\n\n\t\tif ('permanent' in blobStatus) {\n\t\t\treturn {\n\t\t\t\ttype: 'permanent',\n\t\t\t\t...blobStatus.permanent,\n\t\t\t};\n\t\t}\n\n\t\tif ('deletable' in blobStatus) {\n\t\t\treturn {\n\t\t\t\ttype: 'deletable',\n\t\t\t\t...blobStatus.deletable,\n\t\t\t};\n\t\t}\n\n\t\tthrow new StorageNodeError(`Unknown blob status received: ${blobStatus}`);\n\t}\n\n\t/**\n\t * Stores the metadata associated with a registered Walrus blob at this storage\n\t * node. This is a pre-requisite for storing the encoded slivers of the blob. The\n\t * ID of the blob must first be registered on Sui, after which storing the metadata\n\t * becomes possible.\n\t *\n\t * This endpoint may return an error if the node has not yet received the\n\t * registration event from the chain.\n\t */\n\tasync storeBlobMetadata(\n\t\t{ blobId, metadata }: StoreBlobMetadataRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<StoreBlobMetadataResponse> {\n\t\tconst isBcsInput = typeof metadata === 'object' && 'V1' in metadata;\n\t\tconst body = isBcsInput ? BlobMetadata.serialize(metadata).toBytes() : metadata;\n\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/metadata`, {\n\t\t\t...options,\n\t\t\tmethod: 'PUT',\n\t\t\tbody: body as Uint8Array<ArrayBuffer>,\n\t\t\theaders: mergeHeaders({ 'Content-Type': 'application/octet-stream' }, options.headers),\n\t\t});\n\n\t\tconst json: StoreBlobMetadataResponse = await response.json();\n\t\treturn json;\n\t}\n\n\t/**\n\t * Gets the primary or secondary sliver identified by the specified blob ID and\n\t * index. The index should represent a sliver that is assigned to be stored at one\n\t * of the shards managed by this storage node during this epoch.\n\t */\n\tasync getSliver(\n\t\t{ blobId, sliverPairIndex, sliverType }: GetSliverRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetSliverResponse> {\n\t\tconst response = await this.#request(\n\t\t\t`/v1/blobs/${blobId}/slivers/${sliverPairIndex}/${sliverType}`,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\theaders: mergeHeaders({ Accept: 'application/octet-stream' }, options.headers),\n\t\t\t},\n\t\t);\n\n\t\tconst bcsBytes = await response.arrayBuffer();\n\t\treturn
|
|
5
|
-
"mappings": ";;;;;;;;AAAA;AAGA,SAAS,cAAc,oBAAoB,kBAAkB;AAC7D;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAkBP,SAAS,oBAAoB;AAgCtB,MAAM,kBAAkB;AAAA,EAI9B,YAAY,EAAE,OAAO,iBAAiB,SAAS,QAAQ,IAA8B,CAAC,GAAG;AAJnF;AACN;AACA;AACA;AAEC,uBAAK,QAAS,mBAAmB,WAAW;AAC5C,uBAAK,UAAW,WAAW;AAC3B,uBAAK,UAAW;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,gBACL,EAAE,OAAO,GACT,SACmC;AACnC,UAAM,WAAW,MAAM,sBAAK,0CAAL,WAAc,aAAa,MAAM,aAAa;AAAA,MACpE,GAAG;AAAA,MACH,SAAS,aAAa,EAAE,QAAQ,2BAA2B,GAAG,QAAQ,OAAO;AAAA,IAC9E;AAEA,UAAM,WAAW,MAAM,SAAS,YAAY;AAC5C,WAAO,mBAAmB,MAAM,IAAI,WAAW,QAAQ,CAAC;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cACL,EAAE,OAAO,GACT,SACiC;AACjC,UAAM,WAAW,MAAM,sBAAK,0CAAL,WAAc,aAAa,MAAM,WAAW;AAEnE,UAAM,OAAiC,MAAM,SAAS,KAAK;AAC3D,UAAM,aAAa,KAAK,QAAQ;AAEhC,QAAI,eAAe,eAAe;AACjC,aAAO,EAAE,MAAM,cAAc;AAAA,IAC9B;AAEA,QAAI,aAAa,YAAY;AAC5B,aAAO;AAAA,QACN,MAAM;AAAA,QACN,GAAG,WAAW;AAAA,MACf;AAAA,IACD;AAEA,QAAI,eAAe,YAAY;AAC9B,aAAO;AAAA,QACN,MAAM;AAAA,QACN,GAAG,WAAW;AAAA,MACf;AAAA,IACD;AAEA,QAAI,eAAe,YAAY;AAC9B,aAAO;AAAA,QACN,MAAM;AAAA,QACN,GAAG,WAAW;AAAA,MACf;AAAA,IACD;AAEA,UAAM,IAAI,iBAAiB,iCAAiC,UAAU,EAAE;AAAA,EACzE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAWA,MAAM,kBACL,EAAE,QAAQ,SAAS,GACnB,SACqC;AACrC,UAAM,aAAa,OAAO,aAAa,YAAY,QAAQ;AAC3D,UAAM,OAAO,aAAa,aAAa,UAAU,QAAQ,EAAE,QAAQ,IAAI;AAEvE,UAAM,WAAW,MAAM,sBAAK,0CAAL,WAAc,aAAa,MAAM,aAAa;AAAA,MACpE,GAAG;AAAA,MACH,QAAQ;AAAA,MACR;AAAA,MACA,SAAS,aAAa,EAAE,gBAAgB,2BAA2B,GAAG,QAAQ,OAAO;AAAA,IACtF;AAEA,UAAM,OAAkC,MAAM,SAAS,KAAK;AAC5D,WAAO;AAAA,EACR;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAM,UACL,EAAE,QAAQ,iBAAiB,WAAW,GACtC,SAC6B;AAC7B,UAAM,WAAW,MAAM,sBAAK,0CAAL,WACtB,aAAa,MAAM,YAAY,eAAe,IAAI,UAAU,IAC5D;AAAA,MACC,GAAG;AAAA,MACH,SAAS,aAAa,EAAE,QAAQ,2BAA2B,GAAG,QAAQ,OAAO;AAAA,IAC9E;AAGD,UAAM,WAAW,MAAM,SAAS,YAAY;AAC5C,WAAO,
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { BlobMetadata, BlobMetadataWithId, SliverData } from '../utils/bcs.js';\nimport {\n\tConnectionTimeoutError,\n\tStorageNodeAPIError,\n\tStorageNodeError,\n\tUserAbortError,\n} from './error.js';\nimport type {\n\tGetBlobMetadataRequestInput,\n\tGetBlobMetadataResponse,\n\tGetBlobStatusRequestInput,\n\tGetBlobStatusResponse,\n\tGetDeletableBlobConfirmationRequestInput,\n\tGetDeletableBlobConfirmationResponse,\n\tGetPermanentBlobConfirmationRequestInput,\n\tGetPermanentBlobConfirmationResponse,\n\tGetSliverRequestInput,\n\tGetSliverResponse,\n\tRawGetBlobStatusResponse,\n\tStoreBlobMetadataRequestInput,\n\tStoreBlobMetadataResponse,\n\tStoreSliverRequestInput,\n\tStoreSliverResponse,\n} from './types.js';\nimport { mergeHeaders } from './utils.js';\n\nexport type Fetch = (url: RequestInfo, init?: RequestInit) => Promise<Response>;\n\nexport type StorageNodeClientOptions = {\n\t/**\n\t * An optional custom fetch function.\n\t *\n\t * If not provided, defaults to the global `fetch` function (`globalThis.fetch`).\n\t *\n\t * @default globalThis.fetch\n\t */\n\tfetch?: Fetch;\n\n\t/**\n\t * An optional timeout for requests.\n\t * @default 30_000ms (30 seconds)\n\t */\n\ttimeout?: number;\n\n\t/**\n\t * Callback for individual network errors.\n\t */\n\tonError?: (error: Error) => void;\n};\n\nexport type RequestOptions = {\n\tnodeUrl: string;\n\ttimeout?: number;\n\theaders?: ReturnType<typeof mergeHeaders>;\n} & Omit<RequestInit, 'headers'>;\n\nexport class StorageNodeClient {\n\t#fetch: Fetch;\n\t#timeout: number;\n\t#onError?: (error: Error) => void;\n\tconstructor({ fetch: overriddenFetch, timeout, onError }: StorageNodeClientOptions = {}) {\n\t\tthis.#fetch = overriddenFetch ?? globalThis.fetch;\n\t\tthis.#timeout = timeout ?? 30_000;\n\t\tthis.#onError = onError;\n\t}\n\n\t/**\n\t * Gets the metadata associated with a Walrus blob.\n\t */\n\tasync getBlobMetadata(\n\t\t{ blobId }: GetBlobMetadataRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetBlobMetadataResponse> {\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/metadata`, {\n\t\t\t...options,\n\t\t\theaders: mergeHeaders({ Accept: 'application/octet-stream' }, options.headers),\n\t\t});\n\n\t\tconst bcsBytes = await response.arrayBuffer();\n\t\treturn BlobMetadataWithId.parse(new Uint8Array(bcsBytes));\n\t}\n\n\t/**\n\t * Gets the status associated with a Walrus blob.\n\t */\n\tasync getBlobStatus(\n\t\t{ blobId }: GetBlobStatusRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetBlobStatusResponse> {\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/status`, options);\n\n\t\tconst json: RawGetBlobStatusResponse = await response.json();\n\t\tconst blobStatus = json.success.data;\n\n\t\tif (blobStatus === 'nonexistent') {\n\t\t\treturn { type: 'nonexistent' };\n\t\t}\n\n\t\tif ('invalid' in blobStatus) {\n\t\t\treturn {\n\t\t\t\ttype: 'invalid',\n\t\t\t\t...blobStatus.invalid,\n\t\t\t};\n\t\t}\n\n\t\tif ('permanent' in blobStatus) {\n\t\t\treturn {\n\t\t\t\ttype: 'permanent',\n\t\t\t\t...blobStatus.permanent,\n\t\t\t};\n\t\t}\n\n\t\tif ('deletable' in blobStatus) {\n\t\t\treturn {\n\t\t\t\ttype: 'deletable',\n\t\t\t\t...blobStatus.deletable,\n\t\t\t};\n\t\t}\n\n\t\tthrow new StorageNodeError(`Unknown blob status received: ${blobStatus}`);\n\t}\n\n\t/**\n\t * Stores the metadata associated with a registered Walrus blob at this storage\n\t * node. This is a pre-requisite for storing the encoded slivers of the blob. The\n\t * ID of the blob must first be registered on Sui, after which storing the metadata\n\t * becomes possible.\n\t *\n\t * This endpoint may return an error if the node has not yet received the\n\t * registration event from the chain.\n\t */\n\tasync storeBlobMetadata(\n\t\t{ blobId, metadata }: StoreBlobMetadataRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<StoreBlobMetadataResponse> {\n\t\tconst isBcsInput = typeof metadata === 'object' && 'V1' in metadata;\n\t\tconst body = isBcsInput ? BlobMetadata.serialize(metadata).toBytes() : metadata;\n\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/metadata`, {\n\t\t\t...options,\n\t\t\tmethod: 'PUT',\n\t\t\tbody: body as Uint8Array<ArrayBuffer>,\n\t\t\theaders: mergeHeaders({ 'Content-Type': 'application/octet-stream' }, options.headers),\n\t\t});\n\n\t\tconst json: StoreBlobMetadataResponse = await response.json();\n\t\treturn json;\n\t}\n\n\t/**\n\t * Gets the primary or secondary sliver identified by the specified blob ID and\n\t * index. The index should represent a sliver that is assigned to be stored at one\n\t * of the shards managed by this storage node during this epoch.\n\t */\n\tasync getSliver(\n\t\t{ blobId, sliverPairIndex, sliverType }: GetSliverRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetSliverResponse> {\n\t\tconst response = await this.#request(\n\t\t\t`/v1/blobs/${blobId}/slivers/${sliverPairIndex}/${sliverType}`,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\theaders: mergeHeaders({ Accept: 'application/octet-stream' }, options.headers),\n\t\t\t},\n\t\t);\n\n\t\tconst bcsBytes = await response.arrayBuffer();\n\t\treturn new Uint8Array(bcsBytes);\n\t}\n\n\t/**\n\t * Stores a primary or secondary blob sliver at the storage node.\n\t */\n\tasync storeSliver(\n\t\t{ blobId, sliverPairIndex, sliverType, sliver }: StoreSliverRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<StoreSliverResponse> {\n\t\tconst isBcsInput = typeof sliver === 'object' && 'symbols' in sliver;\n\t\tconst body = isBcsInput ? SliverData.serialize(sliver).toBytes() : sliver;\n\n\t\tconst response = await this.#request(\n\t\t\t`/v1/blobs/${blobId}/slivers/${sliverPairIndex}/${sliverType}`,\n\t\t\t{\n\t\t\t\t...options,\n\t\t\t\tmethod: 'PUT',\n\t\t\t\tbody: body as Uint8Array<ArrayBuffer>,\n\t\t\t\theaders: mergeHeaders({ 'Content-Type': 'application/octet-stream' }, options.headers),\n\t\t\t},\n\t\t);\n\n\t\tconst json: StoreSliverResponse = await response.json();\n\t\treturn json;\n\t}\n\n\t/**\n\t * Gets a signed storage confirmation from this storage node, indicating that all shards\n\t * assigned to this storage node for the current epoch have stored their respective slivers.\n\t */\n\tasync getDeletableBlobConfirmation(\n\t\t{ blobId, objectId }: GetDeletableBlobConfirmationRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetDeletableBlobConfirmationResponse> {\n\t\tconst response = await this.#request(\n\t\t\t`/v1/blobs/${blobId}/confirmation/deletable/${objectId}`,\n\t\t\toptions,\n\t\t);\n\n\t\tconst json: GetDeletableBlobConfirmationResponse = await response.json();\n\t\treturn json;\n\t}\n\n\t/**\n\t * Gets a signed storage confirmation from this storage node, indicating that all shards\n\t * assigned to this storage node for the current epoch have stored their respective slivers.\n\t */\n\tasync getPermanentBlobConfirmation(\n\t\t{ blobId }: GetPermanentBlobConfirmationRequestInput,\n\t\toptions: RequestOptions,\n\t): Promise<GetPermanentBlobConfirmationResponse> {\n\t\tconst response = await this.#request(`/v1/blobs/${blobId}/confirmation/permanent`, options);\n\n\t\tconst json: GetPermanentBlobConfirmationResponse = await response.json();\n\t\treturn json;\n\t}\n\n\tasync #request(path: string, options: RequestOptions) {\n\t\tconst { nodeUrl, signal, timeout, ...init } = options;\n\n\t\tif (signal?.aborted) {\n\t\t\tthrow new UserAbortError();\n\t\t}\n\n\t\tconst timeoutSignal = AbortSignal.timeout(timeout ?? this.#timeout);\n\n\t\tlet response: Response | undefined;\n\n\t\ttry {\n\t\t\tconst fetch = this.#fetch;\n\t\t\tresponse = await fetch(`${nodeUrl}${path}`, {\n\t\t\t\t...init,\n\t\t\t\tsignal: signal ? AbortSignal.any([timeoutSignal, signal]) : timeoutSignal,\n\t\t\t});\n\t\t} catch (error) {\n\t\t\tif (signal?.aborted) {\n\t\t\t\tthrow new UserAbortError();\n\t\t\t}\n\n\t\t\tif (error instanceof Error && error.name === 'AbortError') {\n\t\t\t\tconst error = new ConnectionTimeoutError();\n\t\t\t\tthis.#onError?.(error);\n\t\t\t\tthrow error;\n\t\t\t}\n\n\t\t\tthis.#onError?.(error as Error);\n\n\t\t\tthrow error;\n\t\t}\n\n\t\tif (!response.ok) {\n\t\t\tconst errorText = await response.text().catch((reason) => reason);\n\t\t\tconst errorJSON = safeParseJSON(errorText);\n\t\t\tconst errorMessage = errorJSON ? undefined : errorText;\n\t\t\tconst error = StorageNodeAPIError.generate(response.status, errorJSON, errorMessage);\n\t\t\tthis.#onError?.(error);\n\t\t\tthrow error;\n\t\t}\n\n\t\treturn response;\n\t}\n}\n\nfunction safeParseJSON(value: string) {\n\ttry {\n\t\treturn JSON.parse(value);\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n"],
|
|
5
|
+
"mappings": ";;;;;;;;AAAA;AAGA,SAAS,cAAc,oBAAoB,kBAAkB;AAC7D;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAkBP,SAAS,oBAAoB;AAgCtB,MAAM,kBAAkB;AAAA,EAI9B,YAAY,EAAE,OAAO,iBAAiB,SAAS,QAAQ,IAA8B,CAAC,GAAG;AAJnF;AACN;AACA;AACA;AAEC,uBAAK,QAAS,mBAAmB,WAAW;AAC5C,uBAAK,UAAW,WAAW;AAC3B,uBAAK,UAAW;AAAA,EACjB;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,gBACL,EAAE,OAAO,GACT,SACmC;AACnC,UAAM,WAAW,MAAM,sBAAK,0CAAL,WAAc,aAAa,MAAM,aAAa;AAAA,MACpE,GAAG;AAAA,MACH,SAAS,aAAa,EAAE,QAAQ,2BAA2B,GAAG,QAAQ,OAAO;AAAA,IAC9E;AAEA,UAAM,WAAW,MAAM,SAAS,YAAY;AAC5C,WAAO,mBAAmB,MAAM,IAAI,WAAW,QAAQ,CAAC;AAAA,EACzD;AAAA;AAAA;AAAA;AAAA,EAKA,MAAM,cACL,EAAE,OAAO,GACT,SACiC;AACjC,UAAM,WAAW,MAAM,sBAAK,0CAAL,WAAc,aAAa,MAAM,WAAW;AAEnE,UAAM,OAAiC,MAAM,SAAS,KAAK;AAC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,MAAM,MAAM,GAAG,OAAO,GAAG,IAAI,IAAI;AAAA,MAC3C,GAAG;AAAA,MACH,QAAQ,SAAS,YAAY,IAAI,CAAC,eAAe,MAAM,CAAC,IAAI;AAAA,IAC7D,CAAC;AAAA,EACF,SAAS,OAAO;AACf,QAAI,QAAQ,SAAS;AACpB,YAAM,IAAI,eAAe;AAAA,IAC1B;AAEA,QAAI,iBAAiB,SAAS,MAAM,SAAS,cAAc;AAC1D,YAAMA,SAAQ,IAAI,uBAAuB;AACzC,+BAAK,cAAL,8BAAgBA;AAChB,YAAMA;AAAA,IACP;AAEA,6BAAK,cAAL,8BAAgB;AAEhB,UAAM;AAAA,EACP;AAEA,MAAI,CAAC,SAAS,IAAI;AACjB,UAAM,YAAY,MAAM,SAAS,KAAK,EAAE,MAAM,CAAC,WAAW,MAAM;AAChE,UAAM,YAAY,cAAc,SAAS;AACzC,UAAM,eAAe,YAAY,SAAY;AAC7C,UAAM,QAAQ,oBAAoB,SAAS,SAAS,QAAQ,WAAW,YAAY;AACnF,6BAAK,cAAL,8BAAgB;AAChB,UAAM;AAAA,EACP;AAEA,SAAO;AACR;AAGD,SAAS,cAAc,OAAe;AACrC,MAAI;AACH,WAAO,KAAK,MAAM,KAAK;AAAA,EACxB,QAAQ;AACP,WAAO;AAAA,EACR;AACD;",
|
|
6
6
|
"names": ["error"]
|
|
7
7
|
}
|
|
@@ -74,7 +74,7 @@ export type GetSliverRequestInput = {
|
|
|
74
74
|
sliverType: SliverType;
|
|
75
75
|
sliverPairIndex: number;
|
|
76
76
|
};
|
|
77
|
-
export type GetSliverResponse =
|
|
77
|
+
export type GetSliverResponse = Uint8Array;
|
|
78
78
|
export type StoreSliverRequestInput = {
|
|
79
79
|
blobId: string;
|
|
80
80
|
sliver: Uploadable | typeof SliverData.$inferInput;
|
package/dist/esm/utils/quilts.js
CHANGED
|
@@ -30,7 +30,7 @@ function computeSymbolSize(blobsSizes, nColumns, nRows, maxNumColumnsForQuiltInd
|
|
|
30
30
|
);
|
|
31
31
|
let maxVal = Math.ceil(Math.max(...blobsSizes) / (nColumns / blobsSizes.length) * nRows);
|
|
32
32
|
while (minVal < maxVal) {
|
|
33
|
-
const mid = (minVal + maxVal) / 2;
|
|
33
|
+
const mid = Math.floor((minVal + maxVal) / 2);
|
|
34
34
|
if (canBlobsFitIntoMatrix(blobsSizes, nColumns, mid * nRows)) {
|
|
35
35
|
maxVal = mid;
|
|
36
36
|
} else {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/utils/quilts.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/bcs';\nimport type { EncodingType } from '../types.js';\nimport type { QuiltPatchV1 } from './bcs.js';\nimport { QuiltIndexV1, QuiltPatchBlobHeader, QuiltPatchId, QuiltPatchTags } from './bcs.js';\nimport {\n\tfromUrlSafeBase64,\n\tgetSourceSymbols,\n\tMAX_SYMBOL_SIZE_BY_ENCODING_TYPE,\n\tREQUIRED_ALIGNMENT_BY_ENCODING_TYPE,\n\turlSafeBase64,\n} from './index.js';\n\nexport const QUILT_INDEX_SIZE_BYTES_LENGTH = 4;\nexport const QUILT_VERSION_BYTES_LENGTH = 1;\nexport const QUILT_INDEX_PREFIX_SIZE = QUILT_VERSION_BYTES_LENGTH + QUILT_INDEX_SIZE_BYTES_LENGTH;\nexport const QUILT_PATCH_BLOB_HEADER_SIZE = 1 + 4 + 1; // bcs length of QuiltPatchBlobHeader\n\nexport const BLOB_IDENTIFIER_SIZE_BYTES_LENGTH = 2;\nexport const TAGS_SIZE_BYTES_LENGTH = 2;\nexport const MAX_BLOB_IDENTIFIER_BYTES_LENGTH = (1 << (8 * BLOB_IDENTIFIER_SIZE_BYTES_LENGTH)) - 1;\nexport const MAX_NUM_SLIVERS_FOR_QUILT_INDEX = 10;\n\nexport const HAS_TAGS_FLAG = 1 << 0;\n\n/**\n * Finds the minimum symbol size needed to store blobs in a fixed number of columns.\n * Each blob must be stored in consecutive columns exclusively.\n *\n * A binary search is used to find the minimum symbol size:\n * 1. Compute the upper and lower bounds for the symbol size.\n * 2. Check if the all the blobs can be fit into the quilt with the current symbol size.\n * 3. Adjust the bounds based on the result and repeat until the symbol size is found.\n *\n * @param blobsSizes - Slice of blob lengths, including the index size as the first element.\n * Note that the len of the blob_size should be between 1 and n_columns.\n * @param nColumns - Number of columns available.\n * @param nRows - Number of rows available.\n * @param maxNumColumnsForQuiltIndex - The maximum number of columns that can be used to\n * store the quilt index.\n * @param encodingType - The encoding type to use.\n *\n * @returns The minimum symbol size needed.\n **/\nexport function computeSymbolSize(\n\tblobsSizes: number[],\n\tnColumns: number,\n\tnRows: number,\n\tmaxNumColumnsForQuiltIndex: number,\n\tencodingType: EncodingType = 'RS2',\n): number {\n\tif (blobsSizes.length > nColumns) {\n\t\tthrow new Error('Too many blobs, the number of blobs must be less than the number of columns');\n\t}\n\n\tif (blobsSizes.length === 0) {\n\t\tthrow new Error('No blobs provided');\n\t}\n\n\tlet minVal = Math.max(\n\t\tblobsSizes.reduce((acc, size) => acc + size, 0) / (nColumns * nRows),\n\t\tblobsSizes[0] / (nRows * maxNumColumnsForQuiltIndex),\n\t\tMath.ceil(QUILT_INDEX_PREFIX_SIZE / nRows),\n\t);\n\n\tlet maxVal = Math.ceil((Math.max(...blobsSizes) / (nColumns / blobsSizes.length)) * nRows);\n\n\twhile (minVal < maxVal) {\n\t\tconst mid = (minVal + maxVal) / 2;\n\t\tif (canBlobsFitIntoMatrix(blobsSizes, nColumns, mid * nRows)) {\n\t\t\tmaxVal = mid;\n\t\t} else {\n\t\t\tminVal = mid + 1;\n\t\t}\n\t}\n\
|
|
5
|
-
"mappings": "AAGA,SAAS,WAAW;AAGpB,SAAS,cAAc,sBAAsB,cAAc,sBAAsB;AACjF;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEA,MAAM,gCAAgC;AACtC,MAAM,6BAA6B;AACnC,MAAM,0BAA0B,6BAA6B;AAC7D,MAAM,+BAA+B,IAAI,IAAI;AAE7C,MAAM,oCAAoC;AAC1C,MAAM,yBAAyB;AAC/B,MAAM,oCAAoC,KAAM,IAAI,qCAAsC;AAC1F,MAAM,kCAAkC;AAExC,MAAM,gBAAgB,KAAK;AAqB3B,SAAS,kBACf,YACA,UACA,OACA,4BACA,eAA6B,OACpB;AACT,MAAI,WAAW,SAAS,UAAU;AACjC,UAAM,IAAI,MAAM,6EAA6E;AAAA,EAC9F;AAEA,MAAI,WAAW,WAAW,GAAG;AAC5B,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACpC;AAEA,MAAI,SAAS,KAAK;AAAA,IACjB,WAAW,OAAO,CAAC,KAAK,SAAS,MAAM,MAAM,CAAC,KAAK,WAAW;AAAA,IAC9D,WAAW,CAAC,KAAK,QAAQ;AAAA,IACzB,KAAK,KAAK,0BAA0B,KAAK;AAAA,EAC1C;AAEA,MAAI,SAAS,KAAK,KAAM,KAAK,IAAI,GAAG,UAAU,KAAK,WAAW,WAAW,UAAW,KAAK;AAEzF,SAAO,SAAS,QAAQ;AACvB,UAAM,OAAO,SAAS,UAAU;
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '@mysten/bcs';\nimport type { EncodingType } from '../types.js';\nimport type { QuiltPatchV1 } from './bcs.js';\nimport { QuiltIndexV1, QuiltPatchBlobHeader, QuiltPatchId, QuiltPatchTags } from './bcs.js';\nimport {\n\tfromUrlSafeBase64,\n\tgetSourceSymbols,\n\tMAX_SYMBOL_SIZE_BY_ENCODING_TYPE,\n\tREQUIRED_ALIGNMENT_BY_ENCODING_TYPE,\n\turlSafeBase64,\n} from './index.js';\n\nexport const QUILT_INDEX_SIZE_BYTES_LENGTH = 4;\nexport const QUILT_VERSION_BYTES_LENGTH = 1;\nexport const QUILT_INDEX_PREFIX_SIZE = QUILT_VERSION_BYTES_LENGTH + QUILT_INDEX_SIZE_BYTES_LENGTH;\nexport const QUILT_PATCH_BLOB_HEADER_SIZE = 1 + 4 + 1; // bcs length of QuiltPatchBlobHeader\n\nexport const BLOB_IDENTIFIER_SIZE_BYTES_LENGTH = 2;\nexport const TAGS_SIZE_BYTES_LENGTH = 2;\nexport const MAX_BLOB_IDENTIFIER_BYTES_LENGTH = (1 << (8 * BLOB_IDENTIFIER_SIZE_BYTES_LENGTH)) - 1;\nexport const MAX_NUM_SLIVERS_FOR_QUILT_INDEX = 10;\n\nexport const HAS_TAGS_FLAG = 1 << 0;\n\n/**\n * Finds the minimum symbol size needed to store blobs in a fixed number of columns.\n * Each blob must be stored in consecutive columns exclusively.\n *\n * A binary search is used to find the minimum symbol size:\n * 1. Compute the upper and lower bounds for the symbol size.\n * 2. Check if the all the blobs can be fit into the quilt with the current symbol size.\n * 3. Adjust the bounds based on the result and repeat until the symbol size is found.\n *\n * @param blobsSizes - Slice of blob lengths, including the index size as the first element.\n * Note that the len of the blob_size should be between 1 and n_columns.\n * @param nColumns - Number of columns available.\n * @param nRows - Number of rows available.\n * @param maxNumColumnsForQuiltIndex - The maximum number of columns that can be used to\n * store the quilt index.\n * @param encodingType - The encoding type to use.\n *\n * @returns The minimum symbol size needed.\n **/\nexport function computeSymbolSize(\n\tblobsSizes: number[],\n\tnColumns: number,\n\tnRows: number,\n\tmaxNumColumnsForQuiltIndex: number,\n\tencodingType: EncodingType = 'RS2',\n): number {\n\tif (blobsSizes.length > nColumns) {\n\t\tthrow new Error('Too many blobs, the number of blobs must be less than the number of columns');\n\t}\n\n\tif (blobsSizes.length === 0) {\n\t\tthrow new Error('No blobs provided');\n\t}\n\n\tlet minVal = Math.max(\n\t\tblobsSizes.reduce((acc, size) => acc + size, 0) / (nColumns * nRows),\n\t\tblobsSizes[0] / (nRows * maxNumColumnsForQuiltIndex),\n\t\tMath.ceil(QUILT_INDEX_PREFIX_SIZE / nRows),\n\t);\n\n\tlet maxVal = Math.ceil((Math.max(...blobsSizes) / (nColumns / blobsSizes.length)) * nRows);\n\n\twhile (minVal < maxVal) {\n\t\tconst mid = Math.floor((minVal + maxVal) / 2);\n\t\tif (canBlobsFitIntoMatrix(blobsSizes, nColumns, mid * nRows)) {\n\t\t\tmaxVal = mid;\n\t\t} else {\n\t\t\tminVal = mid + 1;\n\t\t}\n\t}\n\tconst symbolSize =\n\t\tMath.ceil(minVal / REQUIRED_ALIGNMENT_BY_ENCODING_TYPE[encodingType]) *\n\t\tREQUIRED_ALIGNMENT_BY_ENCODING_TYPE[encodingType];\n\n\tif (!canBlobsFitIntoMatrix(blobsSizes, nColumns, symbolSize * nRows)) {\n\t\tthrow new Error('Quilt oversize');\n\t}\n\n\tif (symbolSize > MAX_SYMBOL_SIZE_BY_ENCODING_TYPE[encodingType]) {\n\t\tthrow new Error(\n\t\t\t`Quilt oversize: the resulting symbol size ${symbolSize} is larger than the maximum symbol size ${MAX_SYMBOL_SIZE_BY_ENCODING_TYPE[encodingType]}; remove some blobs`,\n\t\t);\n\t}\n\n\treturn symbolSize;\n}\n\nfunction canBlobsFitIntoMatrix(\n\tblobsSizes: number[],\n\tnColumns: number,\n\tcolumnSize: number,\n): boolean {\n\treturn blobsSizes.reduce((acc, size) => acc + Math.ceil(size / columnSize), 0) <= nColumns;\n}\n\nexport function parseQuiltPatchId(id: string) {\n\treturn QuiltPatchId.parse(fromUrlSafeBase64(id));\n}\n\nexport function encodeQuiltPatchId(id: typeof QuiltPatchId.$inferInput) {\n\treturn urlSafeBase64(QuiltPatchId.serialize(id).toBytes());\n}\n\nexport function parseWalrusId(id: string) {\n\tconst bytes = fromUrlSafeBase64(id);\n\n\tif (bytes.length === 32) {\n\t\treturn {\n\t\t\tkind: 'blob' as const,\n\t\t\tid,\n\t\t};\n\t}\n\n\treturn {\n\t\tkind: 'quiltPatch' as const,\n\t\tid: parseQuiltPatchId(id),\n\t};\n}\n\nexport interface EncodeQuiltOptions {\n\tblobs: {\n\t\tcontents: Uint8Array;\n\t\tidentifier: string;\n\t\ttags?: Record<string, string>;\n\t}[];\n\tnumShards: number;\n\tencodingType?: EncodingType;\n}\n\nexport function encodeQuilt({ blobs, numShards, encodingType }: EncodeQuiltOptions) {\n\tconst { primarySymbols: nRows, secondarySymbols: nCols } = getSourceSymbols(\n\t\tnumShards,\n\t\tencodingType,\n\t);\n\n\tconst sortedBlobs = blobs.sort((a, b) => (a.identifier < b.identifier ? -1 : 1));\n\tconst identifiers = new Set<string>();\n\tconst index = {\n\t\tpatches: [] as (typeof QuiltPatchV1.$inferInput & { startIndex: number })[],\n\t};\n\tconst tags = sortedBlobs.map((blob) =>\n\t\tblob.tags && Object.keys(blob.tags).length > 0\n\t\t\t? QuiltPatchTags.serialize(blob.tags).toBytes()\n\t\t\t: null,\n\t);\n\n\tfor (const blob of sortedBlobs) {\n\t\tif (identifiers.has(blob.identifier)) {\n\t\t\tthrow new Error(`Duplicate blob identifier: ${blob.identifier}`);\n\t\t}\n\t\tidentifiers.add(blob.identifier);\n\t\tindex.patches.push({\n\t\t\tstartIndex: 0,\n\t\t\tendIndex: 0,\n\t\t\tidentifier: blob.identifier,\n\t\t\ttags: blob.tags ?? {},\n\t\t});\n\t}\n\n\tconst indexSize = QUILT_INDEX_PREFIX_SIZE + QuiltIndexV1.serialize(index).toBytes().length;\n\tconst blobMetadata = sortedBlobs.map((blob, i) => {\n\t\tconst identifierBytes = bcs.string().serialize(blob.identifier).toBytes();\n\t\tlet metadataSize =\n\t\t\tQUILT_PATCH_BLOB_HEADER_SIZE + BLOB_IDENTIFIER_SIZE_BYTES_LENGTH + identifierBytes.length;\n\n\t\tlet mask = 0;\n\t\tlet offset = 0;\n\n\t\tif (tags[i]) {\n\t\t\tmetadataSize += TAGS_SIZE_BYTES_LENGTH + tags[i].length;\n\t\t\tmask |= HAS_TAGS_FLAG << 0;\n\t\t}\n\n\t\tconst metadata = new Uint8Array(metadataSize);\n\t\tconst metadataView = new DataView(metadata.buffer);\n\n\t\tconst header = QuiltPatchBlobHeader.serialize({\n\t\t\tversion: 1,\n\t\t\tlength: metadataSize - QUILT_PATCH_BLOB_HEADER_SIZE + blob.contents.length,\n\t\t\tmask,\n\t\t}).toBytes();\n\n\t\tmetadata.set(header, offset);\n\t\toffset += header.length;\n\n\t\tmetadataView.setUint16(offset, identifierBytes.length, true);\n\t\toffset += BLOB_IDENTIFIER_SIZE_BYTES_LENGTH;\n\t\tmetadata.set(identifierBytes, offset);\n\t\toffset += identifierBytes.length;\n\n\t\tif (tags[i]) {\n\t\t\tmetadataView.setUint16(offset, tags[i].length, true);\n\t\t\toffset += TAGS_SIZE_BYTES_LENGTH;\n\t\t\tmetadata.set(tags[i], offset);\n\t\t\toffset += tags[i].length;\n\t\t}\n\n\t\treturn metadata;\n\t});\n\n\tconst blobSizes = [\n\t\tindexSize,\n\t\t...sortedBlobs.map((blob, i) => {\n\t\t\tif (blob.identifier.length > MAX_BLOB_IDENTIFIER_BYTES_LENGTH) {\n\t\t\t\tthrow new Error(`Blob identifier too long: ${blob.identifier}`);\n\t\t\t}\n\n\t\t\treturn blobMetadata[i].length + blob.contents.length;\n\t\t}),\n\t];\n\n\tconst symbolSize = computeSymbolSize(\n\t\tblobSizes,\n\t\tnCols,\n\t\tnRows,\n\t\tMAX_NUM_SLIVERS_FOR_QUILT_INDEX,\n\t\tencodingType,\n\t);\n\n\tconst rowSize = symbolSize * nCols;\n\tconst columnSize = symbolSize * nRows;\n\tconst indexColumnsNeeded = Math.ceil(indexSize / columnSize);\n\n\tif (indexColumnsNeeded > MAX_NUM_SLIVERS_FOR_QUILT_INDEX) {\n\t\tthrow new Error('Index too large');\n\t}\n\n\tconst quilt = new Uint8Array(rowSize * nRows);\n\tlet currentColumn = indexColumnsNeeded;\n\n\tfor (let i = 0; i < sortedBlobs.length; i++) {\n\t\tconst blob = sortedBlobs[i];\n\t\tindex.patches[i].startIndex = currentColumn;\n\t\tcurrentColumn += writeBlobToQuilt(\n\t\t\tquilt,\n\t\t\tblob.contents,\n\t\t\trowSize,\n\t\t\tcolumnSize,\n\t\t\tsymbolSize,\n\t\t\tcurrentColumn,\n\t\t\tblobMetadata[i],\n\t\t);\n\t\tindex.patches[i].endIndex = currentColumn;\n\t}\n\n\tconst indexBytes = QuiltIndexV1.serialize(index).toBytes();\n\tconst quiltIndex = new Uint8Array(QUILT_INDEX_PREFIX_SIZE + indexBytes.length);\n\tconst view = new DataView(quiltIndex.buffer);\n\tview.setUint8(0, 1);\n\tview.setUint32(1, indexBytes.length, true);\n\tquiltIndex.set(indexBytes, QUILT_INDEX_PREFIX_SIZE);\n\n\twriteBlobToQuilt(quilt, quiltIndex, rowSize, columnSize, symbolSize, 0);\n\n\treturn { quilt, index };\n}\n\nfunction writeBlobToQuilt(\n\tquilt: Uint8Array,\n\tblob: Uint8Array,\n\trowSize: number,\n\tcolumnSize: number,\n\tsymbolSize: number,\n\tstartColumn: number,\n\tprefix?: Uint8Array,\n) {\n\tconst nRows = columnSize / symbolSize;\n\tlet bytesWritten = 0;\n\n\tif (rowSize % symbolSize !== 0) {\n\t\tthrow new Error('Row size must be divisible by symbol size');\n\t}\n\n\tif (columnSize % symbolSize !== 0) {\n\t\tthrow new Error('Column size must be divisible by symbol size');\n\t}\n\n\tif (prefix) {\n\t\twriteBytes(prefix);\n\t}\n\n\twriteBytes(blob);\n\n\treturn Math.ceil(bytesWritten / columnSize);\n\n\tfunction writeBytes(bytes: Uint8Array) {\n\t\tconst offset = bytesWritten;\n\t\tconst symbolsToSkip = Math.floor(offset / symbolSize);\n\t\tlet remainingOffset = offset % symbolSize;\n\t\tlet currentCol = startColumn + Math.floor(symbolsToSkip / nRows);\n\t\tlet currentRow = symbolsToSkip % nRows;\n\n\t\tlet index = 0;\n\t\twhile (index < bytes.length) {\n\t\t\tconst baseIndex = currentRow * rowSize + currentCol * symbolSize;\n\t\t\tconst startIndex = baseIndex + remainingOffset;\n\t\t\tconst len = Math.min(symbolSize - remainingOffset, bytes.length - index);\n\n\t\t\tfor (let i = 0; i < len; i++) {\n\t\t\t\tquilt[startIndex + i] = bytes[index + i];\n\t\t\t}\n\t\t\tindex += len;\n\t\t\tremainingOffset = 0;\n\t\t\tcurrentRow = (currentRow + 1) % nRows;\n\t\t\tif (currentRow === 0) {\n\t\t\t\tcurrentCol++;\n\t\t\t}\n\t\t}\n\n\t\tbytesWritten += bytes.length;\n\t}\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,WAAW;AAGpB,SAAS,cAAc,sBAAsB,cAAc,sBAAsB;AACjF;AAAA,EACC;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAEA,MAAM,gCAAgC;AACtC,MAAM,6BAA6B;AACnC,MAAM,0BAA0B,6BAA6B;AAC7D,MAAM,+BAA+B,IAAI,IAAI;AAE7C,MAAM,oCAAoC;AAC1C,MAAM,yBAAyB;AAC/B,MAAM,oCAAoC,KAAM,IAAI,qCAAsC;AAC1F,MAAM,kCAAkC;AAExC,MAAM,gBAAgB,KAAK;AAqB3B,SAAS,kBACf,YACA,UACA,OACA,4BACA,eAA6B,OACpB;AACT,MAAI,WAAW,SAAS,UAAU;AACjC,UAAM,IAAI,MAAM,6EAA6E;AAAA,EAC9F;AAEA,MAAI,WAAW,WAAW,GAAG;AAC5B,UAAM,IAAI,MAAM,mBAAmB;AAAA,EACpC;AAEA,MAAI,SAAS,KAAK;AAAA,IACjB,WAAW,OAAO,CAAC,KAAK,SAAS,MAAM,MAAM,CAAC,KAAK,WAAW;AAAA,IAC9D,WAAW,CAAC,KAAK,QAAQ;AAAA,IACzB,KAAK,KAAK,0BAA0B,KAAK;AAAA,EAC1C;AAEA,MAAI,SAAS,KAAK,KAAM,KAAK,IAAI,GAAG,UAAU,KAAK,WAAW,WAAW,UAAW,KAAK;AAEzF,SAAO,SAAS,QAAQ;AACvB,UAAM,MAAM,KAAK,OAAO,SAAS,UAAU,CAAC;AAC5C,QAAI,sBAAsB,YAA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GED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { StorageConfirmation } from './storage-node/types.js';
|
|
2
2
|
import type { EncodingType, ProtocolMessageCertificate } from './types.js';
|
|
3
|
-
import type { BlobMetadata
|
|
3
|
+
import type { BlobMetadata } from './utils/bcs.js';
|
|
4
4
|
export interface EncodedBlob {
|
|
5
|
-
|
|
5
|
+
primarySlivers: Uint8Array[];
|
|
6
|
+
secondarySlivers: Uint8Array[];
|
|
6
7
|
blobId: string;
|
|
7
8
|
metadata: typeof BlobMetadata.$inferInput;
|
|
8
9
|
rootHash: Uint8Array;
|
|
@@ -10,10 +11,12 @@ export interface EncodedBlob {
|
|
|
10
11
|
export declare function getWasmBindings(url?: string): Promise<{
|
|
11
12
|
encodeBlob: (nShards: number, bytes: Uint8Array, encodingType?: EncodingType) => EncodedBlob;
|
|
12
13
|
combineSignatures: (confirmations: StorageConfirmation[], signerIndices: number[]) => ProtocolMessageCertificate;
|
|
13
|
-
decodePrimarySlivers: (blobId: string, nShards: number, size: number | bigint | string, slivers:
|
|
14
|
+
decodePrimarySlivers: (blobId: string, nShards: number, size: number | bigint | string, slivers: Uint8Array[], encodingType?: EncodingType) => Uint8Array;
|
|
14
15
|
getVerifySignature: () => (confirmation: StorageConfirmation, publicKey: Uint8Array) => boolean;
|
|
15
|
-
computeMetadata: (nShards: number, bytes: Uint8Array, encodingType?: EncodingType) =>
|
|
16
|
+
computeMetadata: (nShards: number, bytes: Uint8Array, encodingType?: EncodingType) => {
|
|
16
17
|
blobId: string;
|
|
17
18
|
rootHash: Uint8Array;
|
|
19
|
+
unencodedLength: bigint;
|
|
20
|
+
encodingType: EncodingType;
|
|
18
21
|
};
|
|
19
22
|
}>;
|
package/dist/esm/wasm.js
CHANGED
|
@@ -5,6 +5,7 @@ import init, {
|
|
|
5
5
|
bls12381_min_pk_verify
|
|
6
6
|
} from "@mysten/walrus-wasm";
|
|
7
7
|
import { BlobId, blobIdFromBytes } from "./utils/bcs.js";
|
|
8
|
+
import { getSourceSymbols } from "./utils/index.js";
|
|
8
9
|
async function getWasmBindings(url) {
|
|
9
10
|
await init({ module_or_path: url });
|
|
10
11
|
function encodeBlob(nShards, bytes, encodingType = "RS2") {
|
|
@@ -12,9 +13,17 @@ async function getWasmBindings(url) {
|
|
|
12
13
|
if (encodingType !== "RS2") {
|
|
13
14
|
throw new Error(`Unsupported encoding type: ${encodingType}`);
|
|
14
15
|
}
|
|
15
|
-
const
|
|
16
|
+
const bufferSizes = computeBcsBufferSizes(bytes.length, nShards);
|
|
17
|
+
const primaryBuffers = Array.from({ length: nShards }).map(
|
|
18
|
+
() => new Uint8Array(bufferSizes.primary)
|
|
19
|
+
);
|
|
20
|
+
const secondaryBuffers = Array.from({ length: nShards }).map(
|
|
21
|
+
() => new Uint8Array(bufferSizes.secondary)
|
|
22
|
+
);
|
|
23
|
+
const [metadata, rootHash] = encoder.encode(bytes, primaryBuffers, secondaryBuffers);
|
|
16
24
|
return {
|
|
17
|
-
|
|
25
|
+
primarySlivers: primaryBuffers,
|
|
26
|
+
secondarySlivers: secondaryBuffers,
|
|
18
27
|
blobId: blobIdFromBytes(new Uint8Array(metadata.blob_id)),
|
|
19
28
|
metadata: metadata.metadata,
|
|
20
29
|
rootHash: new Uint8Array(rootHash.Digest)
|
|
@@ -35,15 +44,10 @@ async function getWasmBindings(url) {
|
|
|
35
44
|
if (encodingType !== "RS2") {
|
|
36
45
|
throw new Error(`Unsupported encoding type: ${encodingType}`);
|
|
37
46
|
}
|
|
38
|
-
const
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
...sliver,
|
|
43
|
-
_sliver_type: void 0
|
|
44
|
-
}))
|
|
45
|
-
);
|
|
46
|
-
return new Uint8Array(bytes);
|
|
47
|
+
const blobSize = BigInt(size);
|
|
48
|
+
const outputBuffer = new Uint8Array(Number(blobSize));
|
|
49
|
+
encoder.decode(BlobId.serialize(blobId).toBytes(), blobSize, slivers, outputBuffer);
|
|
50
|
+
return outputBuffer;
|
|
47
51
|
}
|
|
48
52
|
function getVerifySignature() {
|
|
49
53
|
return (confirmation, publicKey) => bls12381_min_pk_verify(
|
|
@@ -54,14 +58,15 @@ async function getWasmBindings(url) {
|
|
|
54
58
|
}
|
|
55
59
|
function computeMetadata(nShards, bytes, encodingType = "RS2") {
|
|
56
60
|
const encoder = new BlobEncoder(nShards);
|
|
57
|
-
const [
|
|
61
|
+
const [blobId, rootHash, unencodedLength, encType] = encoder.compute_metadata(bytes);
|
|
58
62
|
if (encodingType !== "RS2") {
|
|
59
63
|
throw new Error(`Unsupported encoding type: ${encodingType}`);
|
|
60
64
|
}
|
|
61
65
|
return {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
66
|
+
blobId: blobIdFromBytes(new Uint8Array(blobId)),
|
|
67
|
+
rootHash: new Uint8Array(rootHash.Digest),
|
|
68
|
+
unencodedLength: BigInt(unencodedLength),
|
|
69
|
+
encodingType: encType
|
|
65
70
|
};
|
|
66
71
|
}
|
|
67
72
|
return {
|
|
@@ -72,6 +77,35 @@ async function getWasmBindings(url) {
|
|
|
72
77
|
computeMetadata
|
|
73
78
|
};
|
|
74
79
|
}
|
|
80
|
+
function uleb128Size(value) {
|
|
81
|
+
let size = 1;
|
|
82
|
+
value >>= 7;
|
|
83
|
+
while (value !== 0) {
|
|
84
|
+
size++;
|
|
85
|
+
value >>= 7;
|
|
86
|
+
}
|
|
87
|
+
return size;
|
|
88
|
+
}
|
|
89
|
+
function computeBcsBufferSize(dataLength) {
|
|
90
|
+
const ulebSize = uleb128Size(dataLength);
|
|
91
|
+
return ulebSize + dataLength + 2 + 2;
|
|
92
|
+
}
|
|
93
|
+
function computeBcsBufferSizes(blobSize, nShards) {
|
|
94
|
+
const { primarySymbols, secondarySymbols } = getSourceSymbols(nShards);
|
|
95
|
+
let symbolSize = Math.floor((Math.max(blobSize, 1) - 1) / (primarySymbols * secondarySymbols)) + 1;
|
|
96
|
+
if (symbolSize % 2 === 1) {
|
|
97
|
+
symbolSize = symbolSize + 1;
|
|
98
|
+
}
|
|
99
|
+
const primarySliverSize = secondarySymbols * symbolSize;
|
|
100
|
+
const secondarySliverSize = primarySymbols * symbolSize;
|
|
101
|
+
const primaryBcsSize = computeBcsBufferSize(primarySliverSize);
|
|
102
|
+
const secondaryBcsSize = computeBcsBufferSize(secondarySliverSize);
|
|
103
|
+
return {
|
|
104
|
+
nShards,
|
|
105
|
+
primary: primaryBcsSize,
|
|
106
|
+
secondary: secondaryBcsSize
|
|
107
|
+
};
|
|
108
|
+
}
|
|
75
109
|
export {
|
|
76
110
|
getWasmBindings
|
|
77
111
|
};
|
package/dist/esm/wasm.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../src/wasm.ts"],
|
|
4
|
-
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64 } from '@mysten/bcs';\nimport init, {\n\tBlobEncoder,\n\tbls12381_min_pk_aggregate,\n\tbls12381_min_pk_verify,\n} from '@mysten/walrus-wasm';\n\nimport type { StorageConfirmation } from './storage-node/types.js';\nimport type { EncodingType, ProtocolMessageCertificate } from './types.js';\nimport type { BlobMetadata
|
|
5
|
-
"mappings": "AAGA,SAAS,kBAAkB;AAC3B,OAAO;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,SAAS,QAAQ,uBAAuB;
|
|
4
|
+
"sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { fromBase64 } from '@mysten/bcs';\nimport init, {\n\tBlobEncoder,\n\tbls12381_min_pk_aggregate,\n\tbls12381_min_pk_verify,\n} from '@mysten/walrus-wasm';\n\nimport type { StorageConfirmation } from './storage-node/types.js';\nimport type { EncodingType, ProtocolMessageCertificate } from './types.js';\nimport type { BlobMetadata } from './utils/bcs.js';\nimport { BlobId, blobIdFromBytes } from './utils/bcs.js';\nimport { getSourceSymbols } from './utils/index.js';\n\nexport interface EncodedBlob {\n\tprimarySlivers: Uint8Array[];\n\tsecondarySlivers: Uint8Array[];\n\tblobId: string;\n\tmetadata: typeof BlobMetadata.$inferInput;\n\trootHash: Uint8Array;\n}\n\nexport async function getWasmBindings(url?: string) {\n\tawait init({ module_or_path: url });\n\n\tfunction encodeBlob(\n\t\tnShards: number,\n\t\tbytes: Uint8Array,\n\t\tencodingType: EncodingType = 'RS2',\n\t): EncodedBlob {\n\t\tconst encoder = new BlobEncoder(nShards);\n\n\t\tif (encodingType !== 'RS2') {\n\t\t\tthrow new Error(`Unsupported encoding type: ${encodingType}`);\n\t\t}\n\n\t\t// Pre-allocate BCS buffers\n\t\tconst bufferSizes = computeBcsBufferSizes(bytes.length, nShards);\n\t\tconst primaryBuffers = Array.from({ length: nShards }).map(\n\t\t\t() => new Uint8Array(bufferSizes.primary),\n\t\t);\n\t\tconst secondaryBuffers = Array.from({ length: nShards }).map(\n\t\t\t() => new Uint8Array(bufferSizes.secondary),\n\t\t);\n\n\t\tconst [metadata, rootHash] = encoder.encode(bytes, primaryBuffers, secondaryBuffers);\n\n\t\treturn {\n\t\t\tprimarySlivers: primaryBuffers,\n\t\t\tsecondarySlivers: secondaryBuffers,\n\t\t\tblobId: blobIdFromBytes(new Uint8Array(metadata.blob_id)),\n\t\t\tmetadata: metadata.metadata,\n\t\t\trootHash: new Uint8Array(rootHash.Digest),\n\t\t};\n\t}\n\n\tfunction combineSignatures(\n\t\tconfirmations: StorageConfirmation[],\n\t\tsignerIndices: number[],\n\t): ProtocolMessageCertificate {\n\t\tconst signature = bls12381_min_pk_aggregate(\n\t\t\tconfirmations.map((confirmation) => fromBase64(confirmation.signature)),\n\t\t);\n\n\t\treturn {\n\t\t\tsigners: signerIndices,\n\t\t\tserializedMessage: fromBase64(confirmations[0].serializedMessage),\n\t\t\tsignature,\n\t\t};\n\t}\n\n\tfunction decodePrimarySlivers(\n\t\tblobId: string,\n\t\tnShards: number,\n\t\tsize: number | bigint | string,\n\t\tslivers: Uint8Array[],\n\t\tencodingType: EncodingType = 'RS2',\n\t): Uint8Array {\n\t\tconst encoder = new BlobEncoder(nShards);\n\n\t\tif (encodingType !== 'RS2') {\n\t\t\tthrow new Error(`Unsupported encoding type: ${encodingType}`);\n\t\t}\n\n\t\tconst blobSize = BigInt(size);\n\t\tconst outputBuffer = new Uint8Array(Number(blobSize));\n\t\tencoder.decode(BlobId.serialize(blobId).toBytes(), blobSize, slivers, outputBuffer);\n\t\treturn outputBuffer;\n\t}\n\n\tfunction getVerifySignature() {\n\t\treturn (confirmation: StorageConfirmation, publicKey: Uint8Array) =>\n\t\t\tbls12381_min_pk_verify(\n\t\t\t\tfromBase64(confirmation.signature),\n\t\t\t\tpublicKey,\n\t\t\t\tfromBase64(confirmation.serializedMessage),\n\t\t\t);\n\t}\n\n\tfunction computeMetadata(\n\t\tnShards: number,\n\t\tbytes: Uint8Array,\n\t\tencodingType: EncodingType = 'RS2',\n\t): { blobId: string; rootHash: Uint8Array; unencodedLength: bigint; encodingType: EncodingType } {\n\t\tconst encoder = new BlobEncoder(nShards);\n\t\tconst [blobId, rootHash, unencodedLength, encType] = encoder.compute_metadata(bytes);\n\n\t\tif (encodingType !== 'RS2') {\n\t\t\tthrow new Error(`Unsupported encoding type: ${encodingType}`);\n\t\t}\n\n\t\treturn {\n\t\t\tblobId: blobIdFromBytes(new Uint8Array(blobId)),\n\t\t\trootHash: new Uint8Array(rootHash.Digest),\n\t\t\tunencodedLength: BigInt(unencodedLength),\n\t\t\tencodingType: encType as EncodingType,\n\t\t};\n\t}\n\n\treturn {\n\t\tencodeBlob,\n\t\tcombineSignatures,\n\t\tdecodePrimarySlivers,\n\t\tgetVerifySignature,\n\t\tcomputeMetadata,\n\t};\n}\n\nfunction uleb128Size(value: number): number {\n\tlet size = 1;\n\tvalue >>= 7;\n\twhile (value !== 0) {\n\t\tsize++;\n\t\tvalue >>= 7;\n\t}\n\treturn size;\n}\n\nfunction computeBcsBufferSize(dataLength: number): number {\n\tconst ulebSize = uleb128Size(dataLength);\n\treturn ulebSize + dataLength + 2 + 2; // ULEB128 + data + symbol_size + index\n}\n\nfunction computeBcsBufferSizes(blobSize: number, nShards: number) {\n\tconst { primarySymbols, secondarySymbols } = getSourceSymbols(nShards);\n\n\tlet symbolSize =\n\t\tMath.floor((Math.max(blobSize, 1) - 1) / (primarySymbols * secondarySymbols)) + 1;\n\tif (symbolSize % 2 === 1) {\n\t\tsymbolSize = symbolSize + 1;\n\t}\n\n\tconst primarySliverSize = secondarySymbols * symbolSize;\n\tconst secondarySliverSize = primarySymbols * symbolSize;\n\n\tconst primaryBcsSize = computeBcsBufferSize(primarySliverSize);\n\tconst secondaryBcsSize = computeBcsBufferSize(secondarySliverSize);\n\n\treturn {\n\t\tnShards,\n\t\tprimary: primaryBcsSize,\n\t\tsecondary: secondaryBcsSize,\n\t};\n}\n"],
|
|
5
|
+
"mappings": "AAGA,SAAS,kBAAkB;AAC3B,OAAO;AAAA,EACN;AAAA,EACA;AAAA,EACA;AAAA,OACM;AAKP,SAAS,QAAQ,uBAAuB;AACxC,SAAS,wBAAwB;AAUjC,eAAsB,gBAAgB,KAAc;AACnD,QAAM,KAAK,EAAE,gBAAgB,IAAI,CAAC;AAElC,WAAS,WACR,SACA,OACA,eAA6B,OACf;AACd,UAAM,UAAU,IAAI,YAAY,OAAO;AAEvC,QAAI,iBAAiB,OAAO;AAC3B,YAAM,IAAI,MAAM,8BAA8B,YAAY,EAAE;AAAA,IAC7D;AAGA,UAAM,cAAc,sBAAsB,MAAM,QAAQ,OAAO;AAC/D,UAAM,iBAAiB,MAAM,KAAK,EAAE,QAAQ,QAAQ,CAAC,EAAE;AAAA,MACtD,MAAM,IAAI,WAAW,YAAY,OAAO;AAAA,IACzC;AACA,UAAM,mBAAmB,MAAM,KAAK,EAAE,QAAQ,QAAQ,CAAC,EAAE;AAAA,MACxD,MAAM,IAAI,WAAW,YAAY,SAAS;AAAA,IAC3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