UNPKG

@mysten/sui

Version:
1 lines 986 B
{"version":3,"file":"intent.mjs","names":["bcs"],"sources":["../../src/cryptography/intent.ts"],"sourcesContent":["// Copyright (c) Mysten Labs, Inc.\n// SPDX-License-Identifier: Apache-2.0\n\nimport { bcs } from '../bcs/index.js';\n\nexport type IntentScope = Exclude<keyof typeof bcs.IntentScope.$inferType, '$kind'>;\n/**\n * Inserts a domain separator for a message that is being signed\n */\nexport function messageWithIntent(scope: IntentScope, message: Uint8Array) {\n\treturn bcs\n\t\t.IntentMessage(bcs.bytes(message.length))\n\t\t.serialize({\n\t\t\tintent: {\n\t\t\t\tscope: { [scope as 'PersonalMessage']: true },\n\t\t\t\tversion: { V0: true },\n\t\t\t\tappId: { Sui: true },\n\t\t\t},\n\t\t\tvalue: message,\n\t\t})\n\t\t.toBytes();\n}\n"],"mappings":";;;;;;AASA,SAAgB,kBAAkB,OAAoB,SAAqB;AAC1E,QAAOA,OACL,cAAcA,OAAI,MAAM,QAAQ,OAAO,CAAC,CACxC,UAAU;EACV,QAAQ;GACP,OAAO,GAAG,QAA6B,MAAM;GAC7C,SAAS,EAAE,IAAI,MAAM;GACrB,OAAO,EAAE,KAAK,MAAM;GACpB;EACD,OAAO;EACP,CAAC,CACD,SAAS"}